diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2016-08-09 08:43:56 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2016-10-12 11:29:52 +0200 |
commit | bde9c4795a0680549f99bac2509f8520e1b2a738 (patch) | |
tree | bd33f11ced877291008db6490072500da8f7d864 /plugins/ublox/tests | |
parent | 29ace8b12076fc6b8e95dbb32230334c9768c82e (diff) |
ublox: new +URAT? response parser
Diffstat (limited to 'plugins/ublox/tests')
-rw-r--r-- | plugins/ublox/tests/test-modem-helpers-ublox.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/plugins/ublox/tests/test-modem-helpers-ublox.c b/plugins/ublox/tests/test-modem-helpers-ublox.c index 5da9b374..cd333477 100644 --- a/plugins/ublox/tests/test-modem-helpers-ublox.c +++ b/plugins/ublox/tests/test-modem-helpers-ublox.c @@ -318,6 +318,58 @@ test_mode_filtering_sara_u280 (void) } /*****************************************************************************/ +/* URAT? response parser */ + +typedef struct { + const gchar *str; + MMModemMode allowed; + MMModemMode preferred; +} UratReadResponseTest; + +static const UratReadResponseTest urat_read_response_tests[] = { + { + .str = "+URAT: 1,2\r\n", + .allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G), + .preferred = MM_MODEM_MODE_3G, + }, + { + .str = "+URAT: 4,0\r\n", + .allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G | MM_MODEM_MODE_4G), + .preferred = MM_MODEM_MODE_2G, + }, + { + .str = "+URAT: 0\r\n", + .allowed = MM_MODEM_MODE_2G, + .preferred = MM_MODEM_MODE_NONE, + }, + { + .str = "+URAT: 6\r\n", + .allowed = (MM_MODEM_MODE_3G | MM_MODEM_MODE_4G), + .preferred = MM_MODEM_MODE_NONE, + }, +}; + +static void +test_urat_read_response (void) +{ + guint i; + + for (i = 0; i < G_N_ELEMENTS (urat_read_response_tests); i++) { + MMModemMode allowed = MM_MODEM_MODE_NONE; + MMModemMode preferred = MM_MODEM_MODE_NONE; + GError *error = NULL; + gboolean success; + + success = mm_ublox_parse_urat_read_response (urat_read_response_tests[i].str, + &allowed, &preferred, &error); + g_assert_no_error (error); + g_assert (success); + g_assert_cmpuint (urat_read_response_tests[i].allowed, ==, allowed); + g_assert_cmpuint (urat_read_response_tests[i].preferred, ==, preferred); + } +} + +/*****************************************************************************/ void _mm_log (const char *loc, @@ -355,6 +407,7 @@ int main (int argc, char **argv) g_test_add_func ("/MM/ublox/urat/test/response/toby-l201", test_mode_filtering_toby_l201); g_test_add_func ("/MM/ublox/urat/test/response/lisa-u200", test_mode_filtering_lisa_u200); g_test_add_func ("/MM/ublox/urat/test/response/sara-u280", test_mode_filtering_sara_u280); + g_test_add_func ("/MM/ublox/urat/read/response", test_urat_read_response); return g_test_run (); } |