diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2021-03-21 13:44:16 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-03-21 13:44:16 +0100 |
commit | 634682b602dd51efbda42a8b2e8764b9bb0024e2 (patch) | |
tree | 3f70cc23248473a08e6ca68c201b080a08636090 /plugins/cinterion/tests/test-modem-helpers-cinterion.c | |
parent | d01bca493dad933b9df51bec1254c79089ffa1c7 (diff) |
cinterion: make sure FALSE sets GError in parse_smong_response()
The g_regex_match_full() method may return FALSE without setting the
GError, so that case needs to be considered.
In addition to that, the following g_assert() was not doing what it
should have been, as it was comparing the address of the variable and
not the variable itself; rework the code to avoid that as well:
g_assert (access_tech != MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN);
Diffstat (limited to 'plugins/cinterion/tests/test-modem-helpers-cinterion.c')
-rw-r--r-- | plugins/cinterion/tests/test-modem-helpers-cinterion.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/plugins/cinterion/tests/test-modem-helpers-cinterion.c b/plugins/cinterion/tests/test-modem-helpers-cinterion.c index 8ea7d909..efd19b38 100644 --- a/plugins/cinterion/tests/test-modem-helpers-cinterion.c +++ b/plugins/cinterion/tests/test-modem-helpers-cinterion.c @@ -1134,6 +1134,7 @@ test_sind_response_simstatus (void) static void common_test_smong_response (const gchar *response, + gboolean success, MMModemAccessTechnology expected_access_tech) { GError *error = NULL; @@ -1141,10 +1142,15 @@ common_test_smong_response (const gchar *response, MMModemAccessTechnology access_tech; res = mm_cinterion_parse_smong_response (response, &access_tech, &error); - g_assert_no_error (error); - g_assert (res == TRUE); - g_assert_cmpuint (access_tech, ==, expected_access_tech); + if (success) { + g_assert_no_error (error); + g_assert (res); + g_assert_cmpuint (access_tech, ==, expected_access_tech); + } else { + g_assert (error); + g_assert (!res); + } } static void @@ -1155,7 +1161,7 @@ test_smong_response_tc63i (void) "GPRS Monitor\r\n" "BCCH G PBCCH PAT MCC MNC NOM TA RAC # Cell #\r\n" "0073 1 - - 262 02 2 00 01\r\n"; - common_test_smong_response (response, MM_MODEM_ACCESS_TECHNOLOGY_GPRS); + common_test_smong_response (response, TRUE, MM_MODEM_ACCESS_TECHNOLOGY_GPRS); } static void @@ -1167,7 +1173,19 @@ test_smong_response_other (void) "\r\n" "BCCH G PBCCH PAT MCC MNC NOM TA RAC # Cell #\r\n" " 44 1 - - 234 10 - - - \r\n"; - common_test_smong_response (response, MM_MODEM_ACCESS_TECHNOLOGY_GPRS); + common_test_smong_response (response, TRUE, MM_MODEM_ACCESS_TECHNOLOGY_GPRS); +} + +static void +test_smong_response_no_match (void) +{ + const gchar *response = + "\r\n" + "GPRS Monitor\r\n" + "\r\n" + "BCCH K PBCCH PAT MCC MNC NOM TA RAC # Cell #\r\n" + " 44 1 - - 234 10 - - - \r\n"; + common_test_smong_response (response, FALSE, MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN); } /*****************************************************************************/ @@ -1757,6 +1775,7 @@ int main (int argc, char **argv) g_test_add_func ("/MM/cinterion/sind/response/simstatus", test_sind_response_simstatus); g_test_add_func ("/MM/cinterion/smong/response/tc63i", test_smong_response_tc63i); g_test_add_func ("/MM/cinterion/smong/response/other", test_smong_response_other); + g_test_add_func ("/MM/cinterion/smong/response/no-match", test_smong_response_no_match); g_test_add_func ("/MM/cinterion/slcc/urc/empty", test_slcc_urc_empty); g_test_add_func ("/MM/cinterion/slcc/urc/single", test_slcc_urc_single); g_test_add_func ("/MM/cinterion/slcc/urc/multiple", test_slcc_urc_multiple); |