diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2019-06-07 18:06:53 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2019-07-11 23:00:50 +0200 |
commit | dca00271ce8a5020b78e46d6f0e3eca90ef69d67 (patch) | |
tree | 2a279bb9e89aef8fd1d23fcd20264ee972d8747b /src/tests/test-modem-helpers.c | |
parent | d9a7b403eeb12b22f9d63aae9c6956d735cdd97a (diff) |
broadband-modem: implement +CCWA URC handling
Diffstat (limited to 'src/tests/test-modem-helpers.c')
-rw-r--r-- | src/tests/test-modem-helpers.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c index 0e8674d2..714bbab4 100644 --- a/src/tests/test-modem-helpers.c +++ b/src/tests/test-modem-helpers.c @@ -3970,6 +3970,55 @@ test_clip_indication (void) } /*****************************************************************************/ +/* +CCWA URC */ + +typedef struct { + const gchar *str; + const gchar *number; + guint type; + guint class; +} CcwaUrcTest; + +static const CcwaUrcTest ccwa_urc_tests[] = { + { "\r\n+CCWA: \"123456789\",129,1\r\n", "123456789", 129, 1 }, + { "\r\n+CCWA: \"123456789\",129,1,,0\r\n", "123456789", 129, 1 }, + { "\r\n+CCWA: \"123456789\",129,1,,0,,,\r\n", "123456789", 129, 1 }, +}; + +static void +test_ccwa_indication (void) +{ + GRegex *r; + guint i; + + r = mm_voice_ccwa_regex_get (); + + for (i = 0; i < G_N_ELEMENTS (ccwa_urc_tests); i++) { + GMatchInfo *match_info = NULL; + gchar *number; + guint type; + guint class; + + g_assert (g_regex_match (r, ccwa_urc_tests[i].str, 0, &match_info)); + g_assert (g_match_info_matches (match_info)); + + number = mm_get_string_unquoted_from_match_info (match_info, 1); + g_assert_cmpstr (number, ==, ccwa_urc_tests[i].number); + + g_assert (mm_get_uint_from_match_info (match_info, 2, &type)); + g_assert_cmpuint (type, ==, ccwa_urc_tests[i].type); + + g_assert (mm_get_uint_from_match_info (match_info, 3, &class)); + g_assert_cmpuint (class, ==, ccwa_urc_tests[i].class); + + g_free (number); + g_match_info_free (match_info); + } + + g_regex_unref (r); +} + +/*****************************************************************************/ typedef struct { gchar *str; @@ -4281,6 +4330,7 @@ int main (int argc, char **argv) g_test_suite_add (suite, TESTCASE (test_cesq_response_to_signal, NULL)); g_test_suite_add (suite, TESTCASE (test_clip_indication, NULL)); + g_test_suite_add (suite, TESTCASE (test_ccwa_indication, NULL)); g_test_suite_add (suite, TESTCASE (test_parse_uint_list, NULL)); |