This source file includes following definitions.
- setup
- teardown
- START_PARAMETRIZED_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 #define TEST_SUITE_NAME "/lib/widget"
27
28 #include "tests/mctest.h"
29
30 #include "lib/widget.h"
31
32 #define C(x) ((char *) x)
33
34
35
36
37 static void
38 setup (void)
39 {
40 }
41
42
43
44
45 static void
46 teardown (void)
47 {
48 }
49
50
51
52
53
54 static const struct test_hotkey_equal_ds
55 {
56 const hotkey_t hotkey1;
57 const hotkey_t hotkey2;
58 gboolean expected_result;
59 } test_hotkey_equal_ds[] =
60 {
61
62 {
63 { .start = C ("abc"), .hotkey = NULL, .end = NULL },
64 { .start = C ("abc"), .hotkey = NULL, .end = NULL },
65 TRUE
66 },
67
68 {
69 { .start = C (""), .hotkey = C (""), .end = C ("") },
70 { .start = C (""), .hotkey = C (""), .end = C ("") },
71 TRUE
72 },
73
74 {
75 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
76 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
77 TRUE
78 },
79
80 {
81 { .start = C ("abc"), .hotkey = NULL, .end = C ("efg") },
82 { .start = C ("abc"), .hotkey = NULL, .end = C ("efg") },
83 TRUE
84 },
85
86 {
87 { .start = C ("abc"), .hotkey = C ("d"), .end = NULL },
88 { .start = C ("abc"), .hotkey = C ("d"), .end = NULL },
89 TRUE
90 },
91
92 {
93 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
94 { .start = C ("_bc"), .hotkey = C ("d"), .end = C ("efg") },
95 FALSE
96 },
97
98 {
99 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
100 { .start = C ("abc"), .hotkey = C ("_"), .end = C ("efg") },
101 FALSE
102 },
103
104 {
105 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
106 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("_fg") },
107 FALSE
108 },
109
110 {
111 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
112 { .start = C ("adc"), .hotkey = NULL, .end = C ("efg") },
113 FALSE
114 },
115
116 {
117 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
118 { .start = C ("abc"), .hotkey = C ("d"), .end = NULL },
119 FALSE
120 },
121
122 {
123 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
124 { .start = C ("abc"), .hotkey = NULL, .end = NULL },
125 FALSE
126 }
127 };
128
129
130
131
132 START_PARAMETRIZED_TEST (test_hotkey_equal,
133 test_hotkey_equal_ds)
134
135 {
136
137 gboolean result;
138
139
140 result = hotkey_equal (data->hotkey1, data->hotkey2);
141
142
143 ck_assert_int_eq (result, data->expected_result);
144 }
145
146 END_PARAMETRIZED_TEST
147
148
149
150
151 int
152 main (void)
153 {
154 TCase *tc_core;
155
156 tc_core = tcase_create ("Core");
157
158 tcase_add_checked_fixture (tc_core, setup, teardown);
159
160
161 mctest_add_parameterized_test (tc_core, test_hotkey_equal, test_hotkey_equal_ds);
162
163
164 return mctest_run_all (tc_core);
165 }
166
167