This source file includes following definitions.
- 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 static int
44 sign (int n)
45 {
46 return _GL_CMP (n, 0);
47 }
48
49
50
51
52 static const struct str_verscmp_test_struct
53 {
54 const char *s1;
55 const char *s2;
56 int expected_result;
57 } str_verscmp_test_ds[] = {
58 { "", "", 0 },
59 { "a", "a", 0 },
60 { "a", "b", -1 },
61 { "b", "a", 1 },
62 { "000", "00", -1 },
63 { "00", "000", 1 },
64 { "a0", "a", 1 },
65 { "00", "01", -1 },
66 { "01", "010", -1 },
67 { "010", "09", -1 },
68 { "09", "0", -1 },
69 { "9", "10", -1 },
70 { "0a", "0", 1 },
71
72 { a, b, -1 },
73 { b, c, -1 },
74 { a, c, -1 },
75 { b, a, 1 },
76 { c, b, 1 },
77 { c, a, 1 },
78 };
79
80
81 START_TEST (str_verscmp_test)
82 {
83
84 int actual_result;
85 const struct str_verscmp_test_struct *data = &str_verscmp_test_ds[_i];
86
87
88 actual_result = str_verscmp (data->s1, data->s2);
89
90
91 ck_assert_int_eq (sign (actual_result), sign (data->expected_result));
92 }
93 END_TEST
94
95
96
97 int
98 main (void)
99 {
100 TCase *tc_core;
101
102 tc_core = tcase_create ("Core");
103
104
105 mctest_add_parameterized_test (tc_core, str_verscmp_test, str_verscmp_test_ds);
106
107
108 return mctest_run_all (tc_core);
109 }
110
111