pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
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
18static void
19default_literal(void **state)
20{
21 assert_int_equal(pcmk__parse_source(NULL), pcmk__source_literal);
22}
23
24static void
25invalid(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
32static void
33valid(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
45static void
46case_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
58PCMK__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))
G_GNUC_INTERNAL enum pcmk__reference_source pcmk__parse_source(const char *source)
Definition rules.c:805
@ pcmk__source_unknown
@ pcmk__source_literal
@ pcmk__source_meta_attrs
@ pcmk__source_instance_attrs
#define PCMK_VALUE_META
Definition options.h:172
#define PCMK_VALUE_PARAM
Definition options.h:192
#define PCMK_VALUE_LITERAL
Definition options.h:167
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)