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 static const struct test_hotkey_equal_ds
54 {
55 const hotkey_t hotkey1;
56 const hotkey_t hotkey2;
57 gboolean expected_result;
58 } test_hotkey_equal_ds[] = {
59 {
60
61 { .start = C ("abc"), .hotkey = NULL, .end = NULL },
62 { .start = C ("abc"), .hotkey = NULL, .end = NULL },
63 TRUE,
64 },
65 {
66
67 { .start = C (""), .hotkey = C (""), .end = C ("") },
68 { .start = C (""), .hotkey = C (""), .end = C ("") },
69 TRUE,
70 },
71 {
72
73 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
74 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
75 TRUE,
76 },
77 {
78
79 { .start = C ("abc"), .hotkey = NULL, .end = C ("efg") },
80 { .start = C ("abc"), .hotkey = NULL, .end = C ("efg") },
81 TRUE,
82 },
83 {
84
85 { .start = C ("abc"), .hotkey = C ("d"), .end = NULL },
86 { .start = C ("abc"), .hotkey = C ("d"), .end = NULL },
87 TRUE,
88 },
89 {
90
91 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
92 { .start = C ("_bc"), .hotkey = C ("d"), .end = C ("efg") },
93 FALSE,
94 },
95 {
96
97 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
98 { .start = C ("abc"), .hotkey = C ("_"), .end = C ("efg") },
99 FALSE,
100 },
101 {
102
103 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
104 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("_fg") },
105 FALSE,
106 },
107 {
108
109 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
110 { .start = C ("adc"), .hotkey = NULL, .end = C ("efg") },
111 FALSE,
112 },
113 {
114
115 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
116 { .start = C ("abc"), .hotkey = C ("d"), .end = NULL },
117 FALSE,
118 },
119 {
120
121 { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
122 { .start = C ("abc"), .hotkey = NULL, .end = NULL },
123 FALSE,
124 },
125 };
126
127
128 START_PARAMETRIZED_TEST (test_hotkey_equal, test_hotkey_equal_ds)
129 {
130
131 gboolean result;
132
133
134 result = hotkey_equal (data->hotkey1, data->hotkey2);
135
136
137 ck_assert_int_eq (result, data->expected_result);
138 }
139 END_PARAMETRIZED_TEST
140
141
142
143 int
144 main (void)
145 {
146 TCase *tc_core;
147
148 tc_core = tcase_create ("Core");
149
150 tcase_add_checked_fixture (tc_core, setup, teardown);
151
152
153 mctest_add_parameterized_test (tc_core, test_hotkey_equal, test_hotkey_equal_ds);
154
155
156 return mctest_run_all (tc_core);
157 }
158
159