diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2014-08-02 06:18:21 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2014-08-02 12:53:34 +0200 |
commit | 2c64635dd8dae2ecb4d5c684353f606f0f268797 (patch) | |
tree | fe17838d196d97fd9cdf28cb6abe3c863c20413a /src | |
parent | c8fedd8a070dadfb67e8aad9dcf61343de05c0dd (diff) | |
download | libmbim-2c64635dd8dae2ecb4d5c684353f606f0f268797.tar.gz |
libmbim-glib,proxy-helpers: allow merging with empty lists
Diffstat (limited to 'src')
-rw-r--r-- | src/libmbim-glib/mbim-proxy-helpers.c | 13 | ||||
-rw-r--r-- | src/libmbim-glib/test/test-proxy-helpers.c | 36 |
2 files changed, 45 insertions, 4 deletions
diff --git a/src/libmbim-glib/mbim-proxy-helpers.c b/src/libmbim-glib/mbim-proxy-helpers.c index 75864c1..147650e 100644 --- a/src/libmbim-glib/mbim-proxy-helpers.c +++ b/src/libmbim-glib/mbim-proxy-helpers.c @@ -131,14 +131,19 @@ _mbim_proxy_helper_service_subscribe_list_merge (MbimEventEntry **original, guint32 out_idx, out_cid_idx; MbimEventEntry *entry; + if (!merge) + return original; + for (i = 0; merge[i]; i++) { entry = NULL; /* look for matching uuid */ - for (out_idx = 0; original[out_idx]; out_idx++) { - if (mbim_uuid_cmp (&merge[i]->device_service_id, &original[out_idx]->device_service_id)) { - entry = original[out_idx]; - break; + if (original) { + for (out_idx = 0; original[out_idx]; out_idx++) { + if (mbim_uuid_cmp (&merge[i]->device_service_id, &original[out_idx]->device_service_id)) { + entry = original[out_idx]; + break; + } } } diff --git a/src/libmbim-glib/test/test-proxy-helpers.c b/src/libmbim-glib/test/test-proxy-helpers.c index b8792e7..c94813a 100644 --- a/src/libmbim-glib/test/test-proxy-helpers.c +++ b/src/libmbim-glib/test/test-proxy-helpers.c @@ -219,6 +219,23 @@ test_standard_list (void) /*****************************************************************************/ static void +test_merge_standard_list_full_none (void) +{ + MbimEventEntry **list; + guint events_count = 0; + + /* list with all standard services */ + list = _mbim_proxy_helper_service_subscribe_standard_list_new (); + + /* merge */ + list = _mbim_proxy_helper_service_subscribe_list_merge (list, NULL, &events_count); + + check_standard_list (list); + + mbim_event_entry_array_free (list); +} + +static void test_merge_standard_list_full_subset (void) { MbimEventEntry **list; @@ -322,6 +339,23 @@ test_merge_standard_list_subset_full (void) } static void +test_merge_standard_list_none_full (void) +{ + MbimEventEntry **list; + guint events_count = 0; + + /* list with all standard services */ + list = _mbim_proxy_helper_service_subscribe_standard_list_new (); + + /* merge */ + list = _mbim_proxy_helper_service_subscribe_list_merge (NULL, list, &events_count); + + check_standard_list (list); + + mbim_event_entry_array_free (list); +} + +static void test_merge_list_same_service (void) { MbimEventEntry **list; @@ -505,9 +539,11 @@ int main (int argc, char **argv) g_test_add_func ("/libmbim-glib/proxy/parse/single-service/0", test_parse_single_service_0_cids); g_test_add_func ("/libmbim-glib/proxy/parse/single-service/1", test_parse_single_service_1_cids); g_test_add_func ("/libmbim-glib/proxy/parse/single-service/5", test_parse_single_service_5_cids); + g_test_add_func ("/libmbim-glib/proxy/merge/standard/full_none", test_merge_standard_list_full_none); g_test_add_func ("/libmbim-glib/proxy/merge/standard/full_subset", test_merge_standard_list_full_subset); g_test_add_func ("/libmbim-glib/proxy/merge/standard/full_full", test_merge_standard_list_full_full); g_test_add_func ("/libmbim-glib/proxy/merge/standard/subset_full", test_merge_standard_list_subset_full); + g_test_add_func ("/libmbim-glib/proxy/merge/standard/none_full", test_merge_standard_list_none_full); g_test_add_func ("/libmbim-glib/proxy/merge/same-service", test_merge_list_same_service); g_test_add_func ("/libmbim-glib/proxy/merge/different-services", test_merge_list_different_services); g_test_add_func ("/libmbim-glib/proxy/merge/merged-services", test_merge_list_merged_services); |