This source file includes following definitions.
- empty_params
- key_not_in_table
- key_in_table
- main
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11 #include <crm/msg_xml.h>
12
13 #include <stdarg.h>
14 #include <stddef.h>
15 #include <stdint.h>
16 #include <setjmp.h>
17 #include <cmocka.h>
18
19 #include <glib.h>
20
21 static void
22 empty_params(void **state)
23 {
24 GHashTable *tbl = pcmk__strkey_table(free, free);
25
26 assert_null(crm_meta_value(NULL, NULL));
27 assert_null(crm_meta_value(tbl, NULL));
28
29 g_hash_table_destroy(tbl);
30 }
31
32 static void
33 key_not_in_table(void **state)
34 {
35 GHashTable *tbl = pcmk__strkey_table(free, free);
36
37 assert_null(crm_meta_value(tbl, XML_RSC_ATTR_NOTIFY));
38 assert_null(crm_meta_value(tbl, XML_RSC_ATTR_STICKINESS));
39
40 g_hash_table_destroy(tbl);
41 }
42
43 static void
44 key_in_table(void **state)
45 {
46 GHashTable *tbl = pcmk__strkey_table(free, free);
47
48 g_hash_table_insert(tbl, crm_meta_name(XML_RSC_ATTR_NOTIFY), strdup("1"));
49 g_hash_table_insert(tbl, crm_meta_name(XML_RSC_ATTR_STICKINESS), strdup("2"));
50
51 assert_string_equal(crm_meta_value(tbl, XML_RSC_ATTR_NOTIFY), "1");
52 assert_string_equal(crm_meta_value(tbl, XML_RSC_ATTR_STICKINESS), "2");
53
54 g_hash_table_destroy(tbl);
55 }
56
57 int main(int argc, char **argv)
58 {
59 const struct CMUnitTest tests[] = {
60 cmocka_unit_test(empty_params),
61 cmocka_unit_test(key_not_in_table),
62 cmocka_unit_test(key_in_table),
63 };
64
65 cmocka_set_message_output(CM_OUTPUT_TAP);
66 return cmocka_run_group_tests(tests, NULL, NULL);
67 }