diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-09-11 08:21:27 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-09-14 07:05:24 +0200 |
commit | af4f23a1d250b9e348ac2e7dcb874b2f5f3c4c3f (patch) | |
tree | 5836c5ffded879ac55ebc3fbf9e673722b92366b /src/tests/test-modem-helpers.c | |
parent | 8acaf7baa7b2bb585bdbdce556a4c37b3b7d2afe (diff) |
test: new tester for +CDS unsolicited messages
Diffstat (limited to 'src/tests/test-modem-helpers.c')
-rw-r--r-- | src/tests/test-modem-helpers.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c index 8c8bdf01..eee1899b 100644 --- a/src/tests/test-modem-helpers.c +++ b/src/tests/test-modem-helpers.c @@ -16,6 +16,7 @@ #include <glib.h> #include <glib-object.h> #include <string.h> +#include <stdlib.h> #include "mm-modem-helpers.h" #include "mm-log.h" @@ -1478,6 +1479,48 @@ test_parse_operator_id (void *f, gpointer d) } /*****************************************************************************/ +/* Test +CDS unsolicited message parsing */ + +static void +common_parse_cds (const gchar *str, + guint expected_pdu_len, + const gchar *expected_pdu) +{ + GMatchInfo *match_info; + GRegex *regex; + gchar *pdu_len_str; + gchar *pdu; + + regex = mm_3gpp_cds_regex_get (); + g_regex_match (regex, str, 0, &match_info); + g_assert (g_match_info_matches (match_info)); + + pdu_len_str = g_match_info_fetch (match_info, 1); + g_assert (pdu_len_str != NULL); + g_assert_cmpuint ((guint) atoi (pdu_len_str), == , expected_pdu_len); + + pdu = g_match_info_fetch (match_info, 2); + g_assert (pdu != NULL); + + g_assert_cmpstr (pdu, ==, expected_pdu); + + g_free (pdu); + g_free (pdu_len_str); + + g_match_info_free (match_info); + g_regex_unref (regex); +} + +static void +test_parse_cds (void *f, gpointer d) +{ + /* <CR><LF>+CDS: 24<CR><LF>07914356060013F1065A098136395339F6219011700463802190117004638030<CR><LF> */ + common_parse_cds ("\r\n+CDS: 24\r\n07914356060013F1065A098136395339F6219011700463802190117004638030\r\n", + 24, + "07914356060013F1065A098136395339F6219011700463802190117004638030"); +} + +/*****************************************************************************/ void _mm_log (const char *loc, @@ -1586,6 +1629,9 @@ int main (int argc, char **argv) g_test_suite_add (suite, TESTCASE (test_parse_operator_id, NULL)); + + g_test_suite_add (suite, TESTCASE (test_parse_cds, NULL)); + result = g_test_run (); reg_test_data_free (reg_data); |