diff options
author | Ben Chan <benchan@chromium.org> | 2013-09-26 11:07:16 -0700 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2013-09-26 20:23:51 +0200 |
commit | b5ef861d12c7533d89a18454b03e8e3301164bea (patch) | |
tree | d49cbf5d285f623de42879a271c0b388dba4a8b1 /src/tests | |
parent | b786ac0debc7aa5e9a6b0f00bd61e15d9daea049 (diff) |
modem-helpers,sim: auto-detect if ICCID response is character swapped
This patch modifies mm_3gpp_parse_iccid() to auto-detect if an ICCID
response is character swapped or not by comparsing the major industry
identifier part of the ICCID response to the known value (89) for
telecommunication purposes. This addresses the issue where the same AT
command (e.g. AT^ICCID used by the huawei plugin) does not report ICCID
in a consistent format.
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/test-modem-helpers.c | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c index 28d9b12a..88ed0353 100644 --- a/src/tests/test-modem-helpers.c +++ b/src/tests/test-modem-helpers.c @@ -1533,7 +1533,7 @@ test_iccid_parse_quoted_swap_19_digit (void *f, gpointer d) char *parsed; GError *error = NULL; - parsed = mm_3gpp_parse_iccid (raw_iccid, TRUE, &error); + parsed = mm_3gpp_parse_iccid (raw_iccid, &error); g_assert_no_error (error); g_assert_cmpstr (parsed, ==, expected); } @@ -1546,7 +1546,7 @@ test_iccid_parse_unquoted_swap_20_digit (void *f, gpointer d) char *parsed; GError *error = NULL; - parsed = mm_3gpp_parse_iccid (raw_iccid, TRUE, &error); + parsed = mm_3gpp_parse_iccid (raw_iccid, &error); g_assert_no_error (error); g_assert_cmpstr (parsed, ==, expected); } @@ -1559,7 +1559,7 @@ test_iccid_parse_unquoted_unswapped_19_digit (void *f, gpointer d) char *parsed; GError *error = NULL; - parsed = mm_3gpp_parse_iccid (raw_iccid, FALSE, &error); + parsed = mm_3gpp_parse_iccid (raw_iccid, &error); g_assert_no_error (error); g_assert_cmpstr (parsed, ==, expected); } @@ -1572,7 +1572,7 @@ test_iccid_parse_quoted_unswapped_20_digit (void *f, gpointer d) char *parsed; GError *error = NULL; - parsed = mm_3gpp_parse_iccid (raw_iccid, FALSE, &error); + parsed = mm_3gpp_parse_iccid (raw_iccid, &error); g_assert_no_error (error); g_assert_cmpstr (parsed, ==, expected); } @@ -1584,7 +1584,7 @@ test_iccid_parse_short (void *f, gpointer d) char *parsed; GError *error = NULL; - parsed = mm_3gpp_parse_iccid (raw_iccid, TRUE, &error); + parsed = mm_3gpp_parse_iccid (raw_iccid, &error); g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED); } @@ -1595,7 +1595,29 @@ test_iccid_parse_invalid_chars (void *f, gpointer d) char *parsed; GError *error = NULL; - parsed = mm_3gpp_parse_iccid (raw_iccid, TRUE, &error); + parsed = mm_3gpp_parse_iccid (raw_iccid, &error); + g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED); +} + +static void +test_iccid_parse_quoted_invalid_mii (void *f, gpointer d) +{ + const char *raw_iccid = "\"0044200053671052499\""; + char *parsed; + GError *error = NULL; + + parsed = mm_3gpp_parse_iccid (raw_iccid, &error); + g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED); +} + +static void +test_iccid_parse_unquoted_invalid_mii (void *f, gpointer d) +{ + const char *raw_iccid = "0044200053671052499"; + char *parsed; + GError *error = NULL; + + parsed = mm_3gpp_parse_iccid (raw_iccid, &error); g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED); } @@ -2398,6 +2420,8 @@ int main (int argc, char **argv) g_test_suite_add (suite, TESTCASE (test_iccid_parse_quoted_unswapped_20_digit, NULL)); g_test_suite_add (suite, TESTCASE (test_iccid_parse_short, NULL)); g_test_suite_add (suite, TESTCASE (test_iccid_parse_invalid_chars, NULL)); + g_test_suite_add (suite, TESTCASE (test_iccid_parse_quoted_invalid_mii, NULL)); + g_test_suite_add (suite, TESTCASE (test_iccid_parse_unquoted_invalid_mii, NULL)); while (item->devid) { g_test_suite_add (suite, TESTCASE (test_devid_item, (gconstpointer) item)); |