diff options
author | Teijo Kinnunen <teijo.kinnunen@uros.com> | 2021-05-06 14:48:18 +0300 |
---|---|---|
committer | Teijo Kinnunen <teijo.kinnunen@uros.com> | 2021-05-17 12:46:52 +0300 |
commit | 14c4f27ae4a0ccdfec29090b9abd77112fec1516 (patch) | |
tree | 6dd184a3c357864178b897667333102589f1c31c /src/tests/test-modem-helpers.c | |
parent | 98fbd5a156a09d3dc46dbc52946a80450df13abb (diff) |
modem-helpers: add 3 digit MNC output to mm_3gpp_parse_operator_id()
MNC digit count information is lost on conversion to integers. Make it
possible for the caller to get this information through a separate
boolean.
Diffstat (limited to 'src/tests/test-modem-helpers.c')
-rw-r--r-- | src/tests/test-modem-helpers.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c index 3a2f7b66..7fbc489a 100644 --- a/src/tests/test-modem-helpers.c +++ b/src/tests/test-modem-helpers.c @@ -3254,21 +3254,23 @@ static void common_parse_operator_id (const gchar *operator_id, gboolean expected_success, guint16 expected_mcc, - guint16 expected_mnc) + guint16 expected_mnc, + gboolean expected_three_digit_mnc) { guint16 mcc; guint16 mnc; + gboolean three_digit_mnc; gboolean result; GError *error = NULL; if (expected_mcc) { g_debug ("Parsing Operator ID '%s' " - "(%" G_GUINT16_FORMAT ", %" G_GUINT16_FORMAT ")...", - operator_id, expected_mcc, expected_mnc); - result = mm_3gpp_parse_operator_id (operator_id, &mcc, &mnc, &error); + "(%" G_GUINT16_FORMAT ", %" G_GUINT16_FORMAT ", %s)...", + operator_id, expected_mcc, expected_mnc, expected_three_digit_mnc ? "TRUE" : "FALSE"); + result = mm_3gpp_parse_operator_id (operator_id, &mcc, &mnc, &three_digit_mnc, &error); } else { g_debug ("Validating Operator ID '%s'...", operator_id); - result = mm_3gpp_parse_operator_id (operator_id, NULL, NULL, &error); + result = mm_3gpp_parse_operator_id (operator_id, NULL, NULL, NULL, &error); } if (error) @@ -3283,6 +3285,7 @@ common_parse_operator_id (const gchar *operator_id, if (expected_mcc) { g_assert_cmpuint (expected_mcc, ==, mcc); g_assert_cmpuint (expected_mnc, ==, mnc); + g_assert_cmpint (expected_three_digit_mnc, ==, three_digit_mnc); } } else { g_assert (error != NULL); @@ -3295,26 +3298,26 @@ static void test_parse_operator_id (void *f, gpointer d) { /* Valid MCC+MNC(2) */ - common_parse_operator_id ("41201", TRUE, 412, 1); - common_parse_operator_id ("41201", TRUE, 0, 0); + common_parse_operator_id ("41201", TRUE, 412, 1, FALSE); + common_parse_operator_id ("41201", TRUE, 0, 0, FALSE); /* Valid MCC+MNC(3) */ - common_parse_operator_id ("342600", TRUE, 342, 600); - common_parse_operator_id ("342600", TRUE, 0, 0); + common_parse_operator_id ("342600", TRUE, 342, 600, TRUE); + common_parse_operator_id ("342600", TRUE, 0, 0, FALSE); /* Valid MCC+MNC(2, == 0) */ - common_parse_operator_id ("72400", TRUE, 724, 0); - common_parse_operator_id ("72400", TRUE, 0, 0); + common_parse_operator_id ("72400", TRUE, 724, 0, FALSE); + common_parse_operator_id ("72400", TRUE, 0, 0, FALSE); /* Valid MCC+MNC(3, == 0) */ - common_parse_operator_id ("724000", TRUE, 724, 0); - common_parse_operator_id ("724000", TRUE, 0, 0); + common_parse_operator_id ("724000", TRUE, 724, 0, TRUE); + common_parse_operator_id ("724000", TRUE, 0, 0, FALSE); /* Invalid MCC=0 */ - common_parse_operator_id ("000600", FALSE, 0, 0); + common_parse_operator_id ("000600", FALSE, 0, 0, FALSE); /* Invalid, non-digits */ - common_parse_operator_id ("000Z00", FALSE, 0, 0); + common_parse_operator_id ("000Z00", FALSE, 0, 0, FALSE); /* Invalid, short */ - common_parse_operator_id ("123", FALSE, 0, 0); + common_parse_operator_id ("123", FALSE, 0, 0, FALSE); /* Invalid, long */ - common_parse_operator_id ("1234567", FALSE, 0, 0); + common_parse_operator_id ("1234567", FALSE, 0, 0, FALSE); } /*****************************************************************************/ |