This source file includes following definitions.
- null_create_fn
- null_create_fn_2
- invalid_params
- add_format
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/output_internal.h>
14
15 static pcmk__output_t *
16 null_create_fn(char **argv) {
17 return NULL;
18 }
19
20 static pcmk__output_t *
21 null_create_fn_2(char **argv) {
22 return NULL;
23 }
24
25 static void
26 invalid_params(void **state) {
27 pcmk__assert_asserts(pcmk__register_format(NULL, "fake", NULL, NULL));
28 pcmk__assert_asserts(pcmk__register_format(NULL, "", null_create_fn, NULL));
29 pcmk__assert_asserts(pcmk__register_format(NULL, NULL, null_create_fn, NULL));
30 }
31
32 static void
33 add_format(void **state) {
34 GHashTable *formatters = NULL;
35 gpointer value;
36
37
38 assert_null(pcmk__output_formatters());
39
40
41 assert_int_equal(pcmk__register_format(NULL, "fake", null_create_fn, NULL), pcmk_rc_ok);
42 formatters = pcmk__output_formatters();
43 assert_int_equal(g_hash_table_size(formatters), 1);
44
45 value = g_hash_table_lookup(formatters, "fake");
46 assert_ptr_equal(value, null_create_fn);
47
48
49
50
51 assert_int_equal(pcmk__register_format(NULL, "fake", null_create_fn_2, NULL), pcmk_rc_ok);
52 formatters = pcmk__output_formatters();
53 assert_int_equal(g_hash_table_size(formatters), 1);
54
55 value = g_hash_table_lookup(formatters, "fake");
56 assert_ptr_equal(value, null_create_fn_2);
57
58 pcmk__unregister_formats();
59 }
60
61 PCMK__UNIT_TEST(NULL, NULL,
62 cmocka_unit_test(invalid_params),
63 cmocka_unit_test(add_format))