From 98e2228c277523aea5f8777c774b9cf32b64acc5 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 2 Oct 2009 17:48:04 -0500 Subject: [PATCH] Add unit test for 3G STATUS response data --- unit/test-simutil.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/unit/test-simutil.c b/unit/test-simutil.c index 7fc6202f..97ec3454 100644 --- a/unit/test-simutil.c +++ b/unit/test-simutil.c @@ -31,6 +31,7 @@ #include #include "simutil.h" +#include "util.h" const unsigned char valid_efopl[] = { 0x42, 0xf6, 0x1d, 0x00, 0x00, 0xff, 0xfe, 0x01, @@ -92,12 +93,57 @@ static void test_ef_db() g_assert(info); } +static const char *binary_ef = "62178202412183022F058A01058B032F060F8002000A" + "880128"; +static const char *record_ef = "62198205422100200483026F408A01058B036F0607" + "800200808800"; + +static void test_3g_status_data() +{ + unsigned char *response; + long len; + int flen, rlen, str; + unsigned char access[3]; + unsigned short efid; + + response = decode_hex(binary_ef, -1, &len, 0); + + sim_parse_3G_get_response(response, len, &flen, &rlen, &str, + access, &efid); + + g_assert(flen == 10); + g_assert(rlen == 0); + g_assert(str == 0); + g_assert(access[0] == 0x01); + g_assert(access[1] == 0xff); + g_assert(access[2] == 0x44); + g_assert(efid == 0x2F05); + + g_free(response); + + response = decode_hex(record_ef, -1, &len, 0); + + sim_parse_3G_get_response(response, len, &flen, &rlen, &str, + access, &efid); + + g_assert(flen == 0x80); + g_assert(rlen == 0x20); + g_assert(str == 1); + g_assert(access[0] == 0x11); + g_assert(access[1] == 0xff); + g_assert(access[2] == 0x44); + g_assert(efid == 0x6F40); + + g_free(response); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); g_test_add_func("/testsimutil/EONS Handling", test_eons); g_test_add_func("/testsimutil/Elementary File DB", test_ef_db); + g_test_add_func("/testsimutil/3G Status response", test_3g_status_data); return g_test_run(); }