24 different_lists(
void **state)
30 from = g_list_append(from, strdup(
"abc"));
31 from = g_list_append(from, strdup(
"def"));
32 from = g_list_append(from, strdup(
"ghi"));
34 items = g_list_append(items, strdup(
"123"));
35 items = g_list_append(items, strdup(
"456"));
39 assert_int_equal(g_list_length(
result), 3);
40 assert_string_equal(g_list_nth_data(
result, 0),
"abc");
41 assert_string_equal(g_list_nth_data(
result, 1),
"def");
42 assert_string_equal(g_list_nth_data(
result, 2),
"ghi");
45 g_list_free_full(from, free);
46 g_list_free_full(items, free);
50 remove_first_item(
void **state)
56 from = g_list_append(from, strdup(
"abc"));
57 from = g_list_append(from, strdup(
"def"));
58 from = g_list_append(from, strdup(
"ghi"));
60 items = g_list_append(items, strdup(
"abc"));
64 assert_int_equal(g_list_length(
result), 2);
65 assert_string_equal(g_list_nth_data(
result, 0),
"def");
66 assert_string_equal(g_list_nth_data(
result, 1),
"ghi");
69 g_list_free_full(from, free);
70 g_list_free_full(items, free);
74 remove_middle_item(
void **state)
80 from = g_list_append(from, strdup(
"abc"));
81 from = g_list_append(from, strdup(
"def"));
82 from = g_list_append(from, strdup(
"ghi"));
84 items = g_list_append(items, strdup(
"def"));
88 assert_int_equal(g_list_length(
result), 2);
89 assert_string_equal(g_list_nth_data(
result, 0),
"abc");
90 assert_string_equal(g_list_nth_data(
result, 1),
"ghi");
93 g_list_free_full(from, free);
94 g_list_free_full(items, free);
98 remove_last_item(
void **state)
104 from = g_list_append(from, strdup(
"abc"));
105 from = g_list_append(from, strdup(
"def"));
106 from = g_list_append(from, strdup(
"ghi"));
108 items = g_list_append(items, strdup(
"ghi"));
112 assert_int_equal(g_list_length(
result), 2);
113 assert_string_equal(g_list_nth_data(
result, 0),
"abc");
114 assert_string_equal(g_list_nth_data(
result, 1),
"def");
117 g_list_free_full(from, free);
118 g_list_free_full(items, free);
122 remove_all_items(
void **state)
128 from = g_list_append(from, strdup(
"abc"));
129 from = g_list_append(from, strdup(
"def"));
130 from = g_list_append(from, strdup(
"ghi"));
132 items = g_list_append(items, strdup(
"abc"));
133 items = g_list_append(items, strdup(
"def"));
134 items = g_list_append(items, strdup(
"ghi"));
138 assert_int_equal(g_list_length(
result), 0);
141 g_list_free_full(from, free);
142 g_list_free_full(items, free);
148 const struct CMUnitTest tests[] = {
149 cmocka_unit_test(different_lists),
150 cmocka_unit_test(remove_first_item),
151 cmocka_unit_test(remove_middle_item),
152 cmocka_unit_test(remove_last_item),
153 cmocka_unit_test(remove_all_items),
156 cmocka_set_message_output(CM_OUTPUT_TAP);
157 return cmocka_run_group_tests(tests, NULL, NULL);
int main(int argc, char **argv)
GList * pcmk__subtract_lists(GList *from, GList *items, GCompareFunc cmp)
pcmk__action_result_t result