diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2017-08-22 10:35:01 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2017-09-15 10:31:21 -0700 |
commit | 56e71127125d7e60f674925a5a9b6bc47beda07b (patch) | |
tree | 265baff79bcfd0f70d948c4463f1e59b455701e1 | |
parent | ce203a1f742a273694952abb1f14737dbe701481 (diff) |
ublox,tests: define common method to compare bands
-rw-r--r-- | plugins/ublox/tests/test-modem-helpers-ublox.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/plugins/ublox/tests/test-modem-helpers-ublox.c b/plugins/ublox/tests/test-modem-helpers-ublox.c index a4fee0c6..76330e69 100644 --- a/plugins/ublox/tests/test-modem-helpers-ublox.c +++ b/plugins/ublox/tests/test-modem-helpers-ublox.c @@ -488,18 +488,19 @@ test_urat_write_command (void) /* Supported bands */ static void -common_validate_supported_bands (const gchar *model, - const MMModemBand *expected_bands, - guint n_expected_bands) +common_compare_bands (GArray *bands, + const MMModemBand *expected_bands, + guint n_expected_bands) { - GError *error = NULL; - GArray *bands; gchar *bands_str; GArray *expected_bands_array; gchar *expected_bands_str; - bands = mm_ublox_get_supported_bands (model, &error); - g_assert_no_error (error); + if (!expected_bands || !n_expected_bands) { + g_assert (!bands); + return; + } + g_assert (bands); mm_common_bands_garray_sort (bands); bands_str = mm_common_build_bands_string ((MMModemBand *)(bands->data), bands->len); @@ -517,6 +518,21 @@ common_validate_supported_bands (const gchar *model, } static void +common_validate_supported_bands (const gchar *model, + const MMModemBand *expected_bands, + guint n_expected_bands) +{ + GError *error = NULL; + GArray *bands; + + bands = mm_ublox_get_supported_bands (model, &error); + g_assert_no_error (error); + g_assert (bands); + + common_compare_bands (bands, expected_bands, n_expected_bands); +} + +static void test_supported_bands_all (void) { /* All 2G, 3G and 4G bands */ @@ -604,26 +620,12 @@ common_validate_ubandsel_response (const gchar *str, { GError *error = NULL; GArray *bands; - gchar *bands_str; - GArray *expected_bands_array; - gchar *expected_bands_str; bands = mm_ublox_parse_ubandsel_response (str, &error); g_assert_no_error (error); g_assert (bands); - mm_common_bands_garray_sort (bands); - bands_str = mm_common_build_bands_string ((MMModemBand *)(bands->data), bands->len); - g_array_unref (bands); - expected_bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), n_expected_bands); - g_array_append_vals (expected_bands_array, expected_bands, n_expected_bands); - mm_common_bands_garray_sort (expected_bands_array); - expected_bands_str = mm_common_build_bands_string ((MMModemBand *)(expected_bands_array->data), expected_bands_array->len); - g_array_unref (expected_bands_array); - - g_assert_cmpstr (bands_str, ==, expected_bands_str); - g_free (bands_str); - g_free (expected_bands_str); + common_compare_bands (bands, expected_bands, n_expected_bands); } static void |