This source file includes following definitions.
- empty_input
- no_quotes
- not_present
- present
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <crm/common/unittest_internal.h>
13 #include <crm/common/xml_internal.h>
14
15 static void
16 empty_input(void **state) {
17 assert_null(pcmk__xpath_node_id(NULL, "lrm"));
18 assert_null(pcmk__xpath_node_id("", "lrm"));
19 assert_null(pcmk__xpath_node_id("/blah/blah", NULL));
20 assert_null(pcmk__xpath_node_id("/blah/blah", ""));
21 assert_null(pcmk__xpath_node_id(NULL, NULL));
22 }
23
24 static void
25 no_quotes(void **state) {
26 pcmk__assert_asserts(pcmk__xpath_node_id("/some/xpath/lrm[@id=xyz]", "lrm"));
27 }
28
29 static void
30 not_present(void **state) {
31 assert_null(pcmk__xpath_node_id("/some/xpath/string[@id='xyz']", "lrm"));
32 assert_null(pcmk__xpath_node_id("/some/xpath/containing[@id='lrm']", "lrm"));
33 }
34
35 static void
36 present(void **state) {
37 char *s = NULL;
38
39 s = pcmk__xpath_node_id("/some/xpath/containing/lrm[@id='xyz']", "lrm");
40 assert_int_equal(strcmp(s, "xyz"), 0);
41 free(s);
42
43 s = pcmk__xpath_node_id("/some/other/lrm[@id='xyz']/xpath", "lrm");
44 assert_int_equal(strcmp(s, "xyz"), 0);
45 free(s);
46 }
47
48 PCMK__UNIT_TEST(NULL, NULL,
49 cmocka_unit_test(empty_input),
50 cmocka_unit_test(no_quotes),
51 cmocka_unit_test(not_present),
52 cmocka_unit_test(present))