pacemaker  2.1.9-49aab99839
Scalable High-Availability cluster resource manager
pcmk__parse_source_test.c
Go to the documentation of this file.
1 /*
2  * Copyright 2024 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU General Public License version 2
7  * or later (GPLv2+) WITHOUT ANY WARRANTY.
8  */
9 
10 #include <crm_internal.h>
11 
12 #include <stdio.h>
13 
16 #include "crmcommon_private.h"
17 
18 static void
19 default_literal(void **state)
20 {
21  assert_int_equal(pcmk__parse_source(NULL), pcmk__source_literal);
22 }
23 
24 static void
25 invalid(void **state)
26 {
27  assert_int_equal(pcmk__parse_source(""), pcmk__source_unknown);
28  assert_int_equal(pcmk__parse_source(" "), pcmk__source_unknown);
29  assert_int_equal(pcmk__parse_source("params"), pcmk__source_unknown);
30 }
31 
32 static void
33 valid(void **state)
34 {
35  assert_int_equal(pcmk__parse_source(PCMK_VALUE_LITERAL),
37 
38  assert_int_equal(pcmk__parse_source(PCMK_VALUE_PARAM),
40 
41  assert_int_equal(pcmk__parse_source(PCMK_VALUE_META),
43 }
44 
45 static void
46 case_insensitive(void **state)
47 {
48  assert_int_equal(pcmk__parse_source("LITERAL"),
50 
51  assert_int_equal(pcmk__parse_source("Param"),
53 
54  assert_int_equal(pcmk__parse_source("MeTa"),
56 }
57 
58 PCMK__UNIT_TEST(NULL, NULL,
59  cmocka_unit_test(default_literal),
60  cmocka_unit_test(invalid),
61  cmocka_unit_test(valid),
62  cmocka_unit_test(case_insensitive))
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)
#define PCMK_VALUE_META
Definition: options.h:170
#define PCMK_VALUE_PARAM
Definition: options.h:189
#define PCMK_VALUE_LITERAL
Definition: options.h:165
G_GNUC_INTERNAL enum pcmk__reference_source pcmk__parse_source(const char *source)
Definition: rules.c:877