pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
pcmk__list_of_multiple_test.c
Go to the documentation of this file.
1 /*
2  * Copyright 2022 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU General Public License version 2
7  * or later (GPLv2+) WITHOUT ANY WARRANTY.
8  */
9 
10 #include <crm_internal.h>
11 
13 
14 #include <glib.h>
15 
16 static void
17 empty_list(void **state) {
18  assert_false(pcmk__list_of_multiple(NULL));
19 }
20 
21 static void
22 singleton_list(void **state) {
23  GList *lst = NULL;
24 
25  lst = g_list_append(lst, strdup("abc"));
26  assert_false(pcmk__list_of_multiple(lst));
27 
28  g_list_free_full(lst, free);
29 }
30 
31 static void
32 longer_list(void **state) {
33  GList *lst = NULL;
34 
35  lst = g_list_append(lst, strdup("abc"));
36  lst = g_list_append(lst, strdup("xyz"));
37  assert_true(pcmk__list_of_multiple(lst));
38 
39  g_list_free_full(lst, free);
40 }
41 
42 PCMK__UNIT_TEST(NULL, NULL,
43  cmocka_unit_test(empty_list),
44  cmocka_unit_test(singleton_list),
45  cmocka_unit_test(longer_list))
PCMK__UNIT_TEST(NULL, NULL, cmocka_unit_test(bad_input), cmocka_unit_test(not_found), cmocka_unit_test(find_attrB), cmocka_unit_test(find_attrA_matching))