15 static int compare_name_handler(xmlNode *xml,
void *userdata) {
17 assert_string_equal((
char *) userdata, (
const char *) xml->name);
23 " <!-- This is a level 1 node -->\n" 27 " <!-- This is a level 1 node -->\n" 31 " <!-- This is a level 1 node -->\n" 38 bad_input(
void **state) {
47 name_given_test(
void **state) {
51 expect_function_call(compare_name_handler);
52 expect_function_call(compare_name_handler);
53 expect_function_call(compare_name_handler);
60 no_name_given_test(
void **state) {
64 expect_function_call(compare_name_handler);
65 expect_function_call(compare_name_handler);
66 expect_function_call(compare_name_handler);
73 name_doesnt_exist_test(
void **state) {
82 " <!-- Inside a level 1 node -->\n" 84 " <!-- Inside a level 2 node -->\n" 88 " <!-- Inside a level 1 node -->\n" 90 " <!-- Inside a level 2 node -->\n" 92 " <!-- Inside a level 3 node -->\n" 96 " <!-- Inside a level 2 node -->\n" 102 multiple_levels_test(
void **state) {
106 expect_function_call(compare_name_handler);
107 expect_function_call(compare_name_handler);
114 multiple_levels_no_name_test(
void **state) {
118 expect_function_call(compare_name_handler);
119 expect_function_call(compare_name_handler);
127 " <!-- This is node #1 -->\n" 131 " <!-- This is node #2 -->\n" 135 " <!-- This is node #3 -->\n" 141 static int any_of_handler(xmlNode *xml,
void *userdata) {
144 "node1",
"node2",
"node3", NULL));
149 any_of_test(
void **state) {
153 expect_function_call(any_of_handler);
154 expect_function_call(any_of_handler);
155 expect_function_call(any_of_handler);
161 static int stops_on_first_handler(xmlNode *xml,
void *userdata) {
164 if (pcmk__xe_is(xml,
"node1")) {
171 static int stops_on_second_handler(xmlNode *xml,
void *userdata) {
174 if (pcmk__xe_is(xml,
"node2")) {
181 static int stops_on_third_handler(xmlNode *xml,
void *userdata) {
184 if (pcmk__xe_is(xml,
"node3")) {
192 one_of_test(
void **state) {
196 expect_function_call(stops_on_first_handler);
199 expect_function_call(stops_on_second_handler);
202 expect_function_call(stops_on_third_handler);
209 cmocka_unit_test(bad_input),
210 cmocka_unit_test(name_given_test),
211 cmocka_unit_test(no_name_given_test),
212 cmocka_unit_test(name_doesnt_exist_test),
213 cmocka_unit_test(multiple_levels_test),
214 cmocka_unit_test(multiple_levels_no_name_test),
215 cmocka_unit_test(any_of_test),
216 cmocka_unit_test(one_of_test))
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))
xmlNode * string2xml(const char *input)
#define pcmk__assert_asserts(stmt)
void free_xml(xmlNode *child)
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
int pcmk__xe_foreach_child(xmlNode *xml, const char *child_element_name, int(*handler)(xmlNode *xml, void *userdata), void *userdata)