18 different_lists(
void **state)
24 from = g_list_append(from, strdup(
"abc"));
25 from = g_list_append(from, strdup(
"def"));
26 from = g_list_append(from, strdup(
"ghi"));
28 items = g_list_append(items, strdup(
"123"));
29 items = g_list_append(items, strdup(
"456"));
33 assert_int_equal(g_list_length(
result), 3);
34 assert_string_equal(g_list_nth_data(
result, 0),
"abc");
35 assert_string_equal(g_list_nth_data(
result, 1),
"def");
36 assert_string_equal(g_list_nth_data(
result, 2),
"ghi");
39 g_list_free_full(from, free);
40 g_list_free_full(items, free);
44 remove_first_item(
void **state)
50 from = g_list_append(from, strdup(
"abc"));
51 from = g_list_append(from, strdup(
"def"));
52 from = g_list_append(from, strdup(
"ghi"));
54 items = g_list_append(items, strdup(
"abc"));
58 assert_int_equal(g_list_length(
result), 2);
59 assert_string_equal(g_list_nth_data(
result, 0),
"def");
60 assert_string_equal(g_list_nth_data(
result, 1),
"ghi");
63 g_list_free_full(from, free);
64 g_list_free_full(items, free);
68 remove_middle_item(
void **state)
74 from = g_list_append(from, strdup(
"abc"));
75 from = g_list_append(from, strdup(
"def"));
76 from = g_list_append(from, strdup(
"ghi"));
78 items = g_list_append(items, strdup(
"def"));
82 assert_int_equal(g_list_length(
result), 2);
83 assert_string_equal(g_list_nth_data(
result, 0),
"abc");
84 assert_string_equal(g_list_nth_data(
result, 1),
"ghi");
87 g_list_free_full(from, free);
88 g_list_free_full(items, free);
92 remove_last_item(
void **state)
98 from = g_list_append(from, strdup(
"abc"));
99 from = g_list_append(from, strdup(
"def"));
100 from = g_list_append(from, strdup(
"ghi"));
102 items = g_list_append(items, strdup(
"ghi"));
106 assert_int_equal(g_list_length(
result), 2);
107 assert_string_equal(g_list_nth_data(
result, 0),
"abc");
108 assert_string_equal(g_list_nth_data(
result, 1),
"def");
111 g_list_free_full(from, free);
112 g_list_free_full(items, free);
116 remove_all_items(
void **state)
122 from = g_list_append(from, strdup(
"abc"));
123 from = g_list_append(from, strdup(
"def"));
124 from = g_list_append(from, strdup(
"ghi"));
126 items = g_list_append(items, strdup(
"abc"));
127 items = g_list_append(items, strdup(
"def"));
128 items = g_list_append(items, strdup(
"ghi"));
132 assert_int_equal(g_list_length(
result), 0);
135 g_list_free_full(from, free);
136 g_list_free_full(items, free);
140 cmocka_unit_test(different_lists),
141 cmocka_unit_test(remove_first_item),
142 cmocka_unit_test(remove_middle_item),
143 cmocka_unit_test(remove_last_item),
144 cmocka_unit_test(remove_all_items))
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))
pcmk__action_result_t result
GList * pcmk__subtract_lists(GList *from, const GList *items, GCompareFunc cmp)