This source file includes following definitions.
- empty_params
- equal_versions
- unequal_versions
- shorter_versions
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <crm/common/unittest_internal.h>
13
14 static void
15 empty_params(void **state)
16 {
17 assert_int_equal(compare_version(NULL, NULL), 0);
18 assert_int_equal(compare_version(NULL, "abc"), -1);
19 assert_int_equal(compare_version(NULL, "1.0.1"), -1);
20 assert_int_equal(compare_version("abc", NULL), 1);
21 assert_int_equal(compare_version("1.0.1", NULL), 1);
22 }
23
24 static void
25 equal_versions(void **state)
26 {
27 assert_int_equal(compare_version("0.4.7", "0.4.7"), 0);
28 assert_int_equal(compare_version("1.0", "1.0"), 0);
29 }
30
31 static void
32 unequal_versions(void **state)
33 {
34 assert_int_equal(compare_version("0.4.7", "0.4.8"), -1);
35 assert_int_equal(compare_version("0.4.8", "0.4.7"), 1);
36
37 assert_int_equal(compare_version("0.2.3", "0.3"), -1);
38 assert_int_equal(compare_version("0.3", "0.2.3"), 1);
39
40 assert_int_equal(compare_version("0.99", "1.0"), -1);
41 assert_int_equal(compare_version("1.0", "0.99"), 1);
42 }
43
44 static void
45 shorter_versions(void **state)
46 {
47 assert_int_equal(compare_version("1.0", "1.0.1"), -1);
48 assert_int_equal(compare_version("1.0.1", "1.0"), 1);
49 assert_int_equal(compare_version("1.0", "1"), 0);
50 assert_int_equal(compare_version("1", "1.2"), -1);
51 assert_int_equal(compare_version("1.2", "1"), 1);
52 }
53
54 PCMK__UNIT_TEST(NULL, NULL,
55 cmocka_unit_test(empty_params),
56 cmocka_unit_test(equal_versions),
57 cmocka_unit_test(unequal_versions),
58 cmocka_unit_test(shorter_versions))