This source file includes following definitions.
- setup
- teardown
- sign
- START_TEST
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 #define TEST_SUITE_NAME "/lib/strutil"
28
29 #include "tests/mctest.h"
30
31 #include "lib/strutil.h"
32 #include "lib/util.h"
33
34
35
36
37 static char const a[] = "B0075022800016.gbp.corp.com";
38 static char const b[] = "B007502280067.gbp.corp.com";
39 static char const c[] = "B007502357019.GBP.CORP.COM";
40
41
42
43
44 static void
45 setup (void)
46 {
47 }
48
49
50
51
52 static void
53 teardown (void)
54 {
55 }
56
57
58
59 static int
60 sign (int n)
61 {
62 return _GL_CMP (n, 0);
63 }
64
65
66
67
68 static const struct str_verscmp_test_struct
69 {
70 const char *s1;
71 const char *s2;
72 int expected_result;
73 } str_verscmp_test_ds[] = {
74 { "", "", 0 },
75 { "a", "a", 0 },
76 { "a", "b", -1 },
77 { "b", "a", 1 },
78 { "000", "00", -1 },
79 { "00", "000", 1 },
80 { "a0", "a", 1 },
81 { "00", "01", -1 },
82 { "01", "010", -1 },
83 { "010", "09", -1 },
84 { "09", "0", -1 },
85 { "9", "10", -1 },
86 { "0a", "0", 1 },
87
88 { a, b, -1 },
89 { b, c, -1 },
90 { a, c, -1 },
91 { b, a, 1 },
92 { c, b, 1 },
93 { c, a, 1 },
94 };
95
96
97 START_TEST (str_verscmp_test)
98 {
99
100 int actual_result;
101 const struct str_verscmp_test_struct *data = &str_verscmp_test_ds[_i];
102
103
104 actual_result = str_verscmp (data->s1, data->s2);
105
106
107 ck_assert_int_eq (sign (actual_result), sign (data->expected_result));
108 }
109 END_TEST
110
111
112
113 int
114 main (void)
115 {
116 TCase *tc_core;
117
118 tc_core = tcase_create ("Core");
119
120 tcase_add_checked_fixture (tc_core, setup, teardown);
121
122
123 mctest_add_parameterized_test (tc_core, str_verscmp_test, str_verscmp_test_ds);
124
125
126 return mctest_run_all (tc_core);
127 }
128
129