replace unittest framework to bchanf library.
@@ -1,7 +1,7 @@ | ||
1 | 1 | /* |
2 | 2 | * test_subjectparser.c |
3 | 3 | * |
4 | - * Copyright (c) 2009 project bchan | |
4 | + * Copyright (c) 2009-2012 project bchan | |
5 | 5 | * |
6 | 6 | * This software is provided 'as-is', without any express or implied |
7 | 7 | * warranty. In no event will the authors be held liable for any damages |
@@ -24,14 +24,17 @@ | ||
24 | 24 | * |
25 | 25 | */ |
26 | 26 | |
27 | +#include "test.h" | |
28 | + | |
29 | +#include "subjectparser.h" | |
30 | + | |
27 | 31 | #include <btron/btron.h> |
28 | 32 | #include <tcode.h> |
29 | 33 | #include <bstdio.h> |
30 | 34 | #include <bstring.h> |
31 | 35 | |
32 | -#include "test.h" | |
36 | +#include <unittest_driver.h> | |
33 | 37 | |
34 | -#include "subjectparser.h" | |
35 | 38 | #include "subjectcache.h" |
36 | 39 | |
37 | 40 | LOCAL UB test_subjectparser_testdata_01[] = { |
@@ -67,13 +70,13 @@ | ||
67 | 70 | 0x28, 0x35, 0x32, 0x33, 0x29 |
68 | 71 | }; |
69 | 72 | |
70 | -LOCAL TEST_RESULT test_sbjtparser_1() | |
73 | +LOCAL UNITTEST_RESULT test_sbjtparser_1() | |
71 | 74 | { |
72 | 75 | W err; |
73 | 76 | sbjtcache_t *cache; |
74 | 77 | sbjtparser_t *parser; |
75 | 78 | sbjtparser_thread_t *thread = NULL; |
76 | - TEST_RESULT result = TEST_RESULT_PASS; | |
79 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
77 | 80 | |
78 | 81 | cache = sbjtcache_new(); |
79 | 82 | sbjtcache_appenddata(cache, test_subjectparser_testdata_01, strlen(test_subjectparser_testdata_01)); |
@@ -105,22 +108,7 @@ | ||
105 | 108 | return result; |
106 | 109 | } |
107 | 110 | |
108 | -LOCAL VOID test_sbjtparser_printresult(TEST_RESULT (*proc)(), B *test_name) | |
111 | +EXPORT VOID test_sbjtparser_main(unittest_driver_t *driver) | |
109 | 112 | { |
110 | - TEST_RESULT result; | |
111 | - | |
112 | - printf("test_sbjtparser: %s\n", test_name); | |
113 | - printf("---------------------------------------------\n"); | |
114 | - result = proc(); | |
115 | - if (result == TEST_RESULT_PASS) { | |
116 | - printf("--pass---------------------------------------\n"); | |
117 | - } else { | |
118 | - printf("--fail---------------------------------------\n"); | |
119 | - } | |
120 | - printf("---------------------------------------------\n"); | |
113 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtparser_1); | |
121 | 114 | } |
122 | - | |
123 | -EXPORT VOID test_sbjtparser_main() | |
124 | -{ | |
125 | - test_sbjtparser_printresult(test_sbjtparser_1, "test_sbjtparser_1"); | |
126 | -} |
@@ -1,7 +1,7 @@ | ||
1 | 1 | /* |
2 | 2 | * test_subjectcache.c |
3 | 3 | * |
4 | - * Copyright (c) 2009 project bchan | |
4 | + * Copyright (c) 2009-2012 project bchan | |
5 | 5 | * |
6 | 6 | * This software is provided 'as-is', without any express or implied |
7 | 7 | * warranty. In no event will the authors be held liable for any damages |
@@ -24,6 +24,10 @@ | ||
24 | 24 | * |
25 | 25 | */ |
26 | 26 | |
27 | +#include "test.h" | |
28 | + | |
29 | +#include "subjectcache.h" | |
30 | + | |
27 | 31 | #include <btron/btron.h> |
28 | 32 | #include <tcode.h> |
29 | 33 | #include <bstdio.h> |
@@ -31,10 +35,8 @@ | ||
31 | 35 | #include <bstdlib.h> |
32 | 36 | #include <errcode.h> |
33 | 37 | |
34 | -#include "test.h" | |
38 | +#include <unittest_driver.h> | |
35 | 39 | |
36 | -#include "subjectcache.h" | |
37 | - | |
38 | 40 | LOCAL UB test_sbjtcache_testdata_01[] = {"aaaaabbbbbcccccddddd"}; |
39 | 41 | LOCAL UB test_sbjtcache_testdata_01_1[] = {"aaaaa"}; |
40 | 42 | LOCAL UB test_sbjtcache_testdata_01_2[] = {"bbbbb"}; |
@@ -75,10 +77,10 @@ | ||
75 | 77 | |
76 | 78 | /* test_sbjtcache_1 */ |
77 | 79 | |
78 | -LOCAL TEST_RESULT test_sbjtcache_1() | |
80 | +LOCAL UNITTEST_RESULT test_sbjtcache_1() | |
79 | 81 | { |
80 | 82 | sbjtcache_t *cache; |
81 | - TEST_RESULT result = TEST_RESULT_PASS; | |
83 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
82 | 84 | UB *host; |
83 | 85 | W host_len; |
84 | 86 |
@@ -86,7 +88,7 @@ | ||
86 | 88 | |
87 | 89 | sbjtcache_gethost(cache, &host, &host_len); |
88 | 90 | if ((host != NULL)||(host_len != 0)) { |
89 | - result = TEST_RESULT_FAIL; | |
91 | + result = UNITTEST_RESULT_FAIL; | |
90 | 92 | } |
91 | 93 | |
92 | 94 | sbjtcache_delete(cache); |
@@ -96,10 +98,10 @@ | ||
96 | 98 | |
97 | 99 | /* test_sbjtcache_2 */ |
98 | 100 | |
99 | -LOCAL TEST_RESULT test_sbjtcache_2() | |
101 | +LOCAL UNITTEST_RESULT test_sbjtcache_2() | |
100 | 102 | { |
101 | 103 | sbjtcache_t *cache; |
102 | - TEST_RESULT result = TEST_RESULT_PASS; | |
104 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
103 | 105 | UB *host; |
104 | 106 | W err, host_len, cmp; |
105 | 107 |
@@ -107,7 +109,7 @@ | ||
107 | 109 | |
108 | 110 | err = sbjtcache_updatehost(cache, test_sbjtcache_testdata_04, strlen(test_sbjtcache_testdata_04)); |
109 | 111 | if (err < 0) { |
110 | - result = TEST_RESULT_FAIL; | |
112 | + result = UNITTEST_RESULT_FAIL; | |
111 | 113 | } |
112 | 114 | |
113 | 115 | sbjtcache_gethost(cache, &host, &host_len); |
@@ -114,7 +116,7 @@ | ||
114 | 116 | cmp = memcmp(host, test_sbjtcache_testdata_04, host_len); |
115 | 117 | if (cmp != 0) { |
116 | 118 | printf("sbjtcache_gethost: data error\n"); |
117 | - result = TEST_RESULT_FAIL; | |
119 | + result = UNITTEST_RESULT_FAIL; | |
118 | 120 | } |
119 | 121 | |
120 | 122 | sbjtcache_delete(cache); |
@@ -124,10 +126,10 @@ | ||
124 | 126 | |
125 | 127 | /* test_sbjtcache_3 */ |
126 | 128 | |
127 | -LOCAL TEST_RESULT test_sbjtcache_3() | |
129 | +LOCAL UNITTEST_RESULT test_sbjtcache_3() | |
128 | 130 | { |
129 | 131 | sbjtcache_t *cache; |
130 | - TEST_RESULT result = TEST_RESULT_PASS; | |
132 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
131 | 133 | UB *board; |
132 | 134 | W board_len; |
133 | 135 |
@@ -135,7 +137,7 @@ | ||
135 | 137 | |
136 | 138 | sbjtcache_getboard(cache, &board, &board_len); |
137 | 139 | if ((board != NULL)||(board_len != 0)) { |
138 | - result = TEST_RESULT_FAIL; | |
140 | + result = UNITTEST_RESULT_FAIL; | |
139 | 141 | } |
140 | 142 | |
141 | 143 | sbjtcache_delete(cache); |
@@ -145,10 +147,10 @@ | ||
145 | 147 | |
146 | 148 | /* test_sbjtcache_4 */ |
147 | 149 | |
148 | -LOCAL TEST_RESULT test_sbjtcache_4() | |
150 | +LOCAL UNITTEST_RESULT test_sbjtcache_4() | |
149 | 151 | { |
150 | 152 | sbjtcache_t *cache; |
151 | - TEST_RESULT result = TEST_RESULT_PASS; | |
153 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
152 | 154 | UB *board; |
153 | 155 | W err, board_len, cmp; |
154 | 156 |
@@ -156,7 +158,7 @@ | ||
156 | 158 | |
157 | 159 | err = sbjtcache_updateboard(cache, test_sbjtcache_testdata_05, strlen(test_sbjtcache_testdata_05)); |
158 | 160 | if (err < 0) { |
159 | - result = TEST_RESULT_FAIL; | |
161 | + result = UNITTEST_RESULT_FAIL; | |
160 | 162 | } |
161 | 163 | |
162 | 164 | sbjtcache_getboard(cache, &board, &board_len); |
@@ -163,7 +165,7 @@ | ||
163 | 165 | cmp = memcmp(board, test_sbjtcache_testdata_05, board_len); |
164 | 166 | if (cmp != 0) { |
165 | 167 | printf("sbjtcache_getboard: data error\n"); |
166 | - result = TEST_RESULT_FAIL; | |
168 | + result = UNITTEST_RESULT_FAIL; | |
167 | 169 | } |
168 | 170 | |
169 | 171 | sbjtcache_delete(cache); |
@@ -173,10 +175,10 @@ | ||
173 | 175 | |
174 | 176 | /* test_sbjtcache_5 */ |
175 | 177 | |
176 | -LOCAL TEST_RESULT test_sbjtcache_5_testseq() | |
178 | +LOCAL UNITTEST_RESULT test_sbjtcache_5_testseq() | |
177 | 179 | { |
178 | 180 | sbjtcache_t *cache; |
179 | - TEST_RESULT result = TEST_RESULT_PASS; | |
181 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
180 | 182 | UB *header; |
181 | 183 | W err, header_len, cmp; |
182 | 184 |
@@ -186,18 +188,18 @@ | ||
186 | 188 | if (err < 0) { |
187 | 189 | printf("sbjtcache_updatelataestheade error\n"); |
188 | 190 | sbjtcache_delete(cache); |
189 | - return TEST_RESULT_FAIL; | |
191 | + return UNITTEST_RESULT_FAIL; | |
190 | 192 | } |
191 | 193 | |
192 | 194 | sbjtcache_getlatestheader(cache, &header, &header_len); |
193 | 195 | if (header_len != strlen(test_sbjtcache_testdata_07)) { |
194 | 196 | printf("sbjtcache_getlatestheader: length error\n"); |
195 | - result = TEST_RESULT_FAIL; | |
197 | + result = UNITTEST_RESULT_FAIL; | |
196 | 198 | } |
197 | 199 | cmp = memcmp(header, test_sbjtcache_testdata_07, header_len); |
198 | 200 | if (cmp != 0) { |
199 | 201 | printf("sbjtcache_getlatestheader: data error\n"); |
200 | - result = TEST_RESULT_FAIL; | |
202 | + result = UNITTEST_RESULT_FAIL; | |
201 | 203 | } |
202 | 204 | |
203 | 205 | sbjtcache_delete(cache); |
@@ -205,7 +207,7 @@ | ||
205 | 207 | return result; |
206 | 208 | } |
207 | 209 | |
208 | -LOCAL TEST_RESULT test_sbjtcache_5() | |
210 | +LOCAL UNITTEST_RESULT test_sbjtcache_5() | |
209 | 211 | { |
210 | 212 | return test_sbjtcache_5_testseq(); |
211 | 213 | } |
@@ -212,10 +214,10 @@ | ||
212 | 214 | |
213 | 215 | /* test_sbjtcache_6 */ |
214 | 216 | |
215 | -LOCAL TEST_RESULT test_sbjtcache_6_testseq() | |
217 | +LOCAL UNITTEST_RESULT test_sbjtcache_6_testseq() | |
216 | 218 | { |
217 | 219 | sbjtcache_t *cache; |
218 | - TEST_RESULT result = TEST_RESULT_PASS; | |
220 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
219 | 221 | UB *header; |
220 | 222 | W err, header_len, cmp; |
221 | 223 |
@@ -225,24 +227,24 @@ | ||
225 | 227 | if (err < 0) { |
226 | 228 | printf("sbjtcache_updatelataestheade error\n"); |
227 | 229 | sbjtcache_delete(cache); |
228 | - return TEST_RESULT_FAIL; | |
230 | + return UNITTEST_RESULT_FAIL; | |
229 | 231 | } |
230 | 232 | err = sbjtcache_updatelatestheader(cache, test_sbjtcache_testdata_02, strlen(test_sbjtcache_testdata_02)); |
231 | 233 | if (err < 0) { |
232 | 234 | printf("sbjtcache_updatelataestheade error\n"); |
233 | 235 | sbjtcache_delete(cache); |
234 | - return TEST_RESULT_FAIL; | |
236 | + return UNITTEST_RESULT_FAIL; | |
235 | 237 | } |
236 | 238 | |
237 | 239 | sbjtcache_getlatestheader(cache, &header, &header_len); |
238 | 240 | if (header_len != strlen(test_sbjtcache_testdata_02)) { |
239 | 241 | printf("sbjtcache_getlatestheader: length error\n"); |
240 | - result = TEST_RESULT_FAIL; | |
242 | + result = UNITTEST_RESULT_FAIL; | |
241 | 243 | } |
242 | 244 | cmp = memcmp(header, test_sbjtcache_testdata_02, header_len); |
243 | 245 | if (cmp != 0) { |
244 | 246 | printf("sbjtcache_getlatestheader: data error\n"); |
245 | - result = TEST_RESULT_FAIL; | |
247 | + result = UNITTEST_RESULT_FAIL; | |
246 | 248 | } |
247 | 249 | |
248 | 250 | sbjtcache_delete(cache); |
@@ -250,7 +252,7 @@ | ||
250 | 252 | return result; |
251 | 253 | } |
252 | 254 | |
253 | -LOCAL TEST_RESULT test_sbjtcache_6() | |
255 | +LOCAL UNITTEST_RESULT test_sbjtcache_6() | |
254 | 256 | { |
255 | 257 | return test_sbjtcache_6_testseq(); |
256 | 258 | } |
@@ -257,10 +259,10 @@ | ||
257 | 259 | |
258 | 260 | /* test_sbjtcache_7 */ |
259 | 261 | |
260 | -LOCAL TEST_RESULT test_sbjtcache_7_testseq() | |
262 | +LOCAL UNITTEST_RESULT test_sbjtcache_7_testseq() | |
261 | 263 | { |
262 | 264 | sbjtcache_t *cache; |
263 | - TEST_RESULT result = TEST_RESULT_PASS; | |
265 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
264 | 266 | UB *header; |
265 | 267 | W header_len; |
266 | 268 |
@@ -269,11 +271,11 @@ | ||
269 | 271 | sbjtcache_getlatestheader(cache, &header, &header_len); |
270 | 272 | if (header != NULL) { |
271 | 273 | printf("sbjtcache_getlatestheader: data error\n"); |
272 | - result = TEST_RESULT_FAIL; | |
274 | + result = UNITTEST_RESULT_FAIL; | |
273 | 275 | } |
274 | 276 | if (header_len != 0) { |
275 | 277 | printf("sbjtcache_getlatestheader: length error\n"); |
276 | - result = TEST_RESULT_FAIL; | |
278 | + result = UNITTEST_RESULT_FAIL; | |
277 | 279 | } |
278 | 280 | |
279 | 281 | sbjtcache_delete(cache); |
@@ -281,7 +283,7 @@ | ||
281 | 283 | return result; |
282 | 284 | } |
283 | 285 | |
284 | -LOCAL TEST_RESULT test_sbjtcache_7() | |
286 | +LOCAL UNITTEST_RESULT test_sbjtcache_7() | |
285 | 287 | { |
286 | 288 | return test_sbjtcache_7_testseq(); |
287 | 289 | } |
@@ -288,12 +290,12 @@ | ||
288 | 290 | |
289 | 291 | /* test_sbjtcache_8 */ |
290 | 292 | |
291 | -LOCAL TEST_RESULT test_sbjtcache_8_testseq() | |
293 | +LOCAL UNITTEST_RESULT test_sbjtcache_8_testseq() | |
292 | 294 | { |
293 | 295 | W err; |
294 | 296 | sbjtcache_t *cache; |
295 | 297 | sbjtcache_datareadcontext_t *context; |
296 | - TEST_RESULT result = TEST_RESULT_PASS; | |
298 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
297 | 299 | Bool ok; |
298 | 300 | |
299 | 301 | cache = sbjtcache_new(); |
@@ -302,25 +304,25 @@ | ||
302 | 304 | if (err < 0) { |
303 | 305 | printf("sbjtcache_appenddata error 1\n"); |
304 | 306 | sbjtcache_delete(cache); |
305 | - return TEST_RESULT_FAIL; | |
307 | + return UNITTEST_RESULT_FAIL; | |
306 | 308 | } |
307 | 309 | err = sbjtcache_appenddata(cache, test_sbjtcache_testdata_01_2, strlen(test_sbjtcache_testdata_01_2)); |
308 | 310 | if (err < 0) { |
309 | 311 | printf("sbjtcache_appenddata error 2\n"); |
310 | 312 | sbjtcache_delete(cache); |
311 | - return TEST_RESULT_FAIL; | |
313 | + return UNITTEST_RESULT_FAIL; | |
312 | 314 | } |
313 | 315 | err = sbjtcache_appenddata(cache, test_sbjtcache_testdata_01_3, strlen(test_sbjtcache_testdata_01_3)); |
314 | 316 | if (err < 0) { |
315 | 317 | printf("sbjtcache_appenddata error 3\n"); |
316 | 318 | sbjtcache_delete(cache); |
317 | - return TEST_RESULT_FAIL; | |
319 | + return UNITTEST_RESULT_FAIL; | |
318 | 320 | } |
319 | 321 | err = sbjtcache_appenddata(cache, test_sbjtcache_testdata_01_4, strlen(test_sbjtcache_testdata_01_4)); |
320 | 322 | if (err < 0) { |
321 | 323 | printf("sbjtcache_appenddata error 4\n"); |
322 | 324 | sbjtcache_delete(cache); |
323 | - return TEST_RESULT_FAIL; | |
325 | + return UNITTEST_RESULT_FAIL; | |
324 | 326 | } |
325 | 327 | |
326 | 328 | context = sbjtcache_startdataread(cache, 0); |
@@ -327,11 +329,11 @@ | ||
327 | 329 | if (context == NULL) { |
328 | 330 | printf("sbjtcache_startdataread error\n"); |
329 | 331 | sbjtcache_delete(cache); |
330 | - return TEST_RESULT_FAIL; | |
332 | + return UNITTEST_RESULT_FAIL; | |
331 | 333 | } |
332 | 334 | ok = test_sbjtcache_util_cmp_ctx_str(context, test_sbjtcache_testdata_01, strlen(test_sbjtcache_testdata_01)); |
333 | 335 | if (ok != True) { |
334 | - result = TEST_RESULT_FAIL; | |
336 | + result = UNITTEST_RESULT_FAIL; | |
335 | 337 | } |
336 | 338 | sbjtcache_enddataread(cache, context); |
337 | 339 |
@@ -340,7 +342,7 @@ | ||
340 | 342 | return result; |
341 | 343 | } |
342 | 344 | |
343 | -LOCAL TEST_RESULT test_sbjtcache_8() | |
345 | +LOCAL UNITTEST_RESULT test_sbjtcache_8() | |
344 | 346 | { |
345 | 347 | return test_sbjtcache_8_testseq(); |
346 | 348 | } |
@@ -347,12 +349,12 @@ | ||
347 | 349 | |
348 | 350 | /* test_sbjtcache_9 */ |
349 | 351 | |
350 | -LOCAL TEST_RESULT test_sbjtcache_9_testseq() | |
352 | +LOCAL UNITTEST_RESULT test_sbjtcache_9_testseq() | |
351 | 353 | { |
352 | 354 | W err; |
353 | 355 | sbjtcache_t *cache; |
354 | 356 | sbjtcache_datareadcontext_t *context; |
355 | - TEST_RESULT result = TEST_RESULT_PASS; | |
357 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
356 | 358 | UB *bin_cache; |
357 | 359 | W len_cache; |
358 | 360 | Bool ok; |
@@ -363,35 +365,35 @@ | ||
363 | 365 | if (err < 0) { |
364 | 366 | printf("sbjtcache_appenddata error 1\n"); |
365 | 367 | sbjtcache_delete(cache); |
366 | - return TEST_RESULT_FAIL; | |
368 | + return UNITTEST_RESULT_FAIL; | |
367 | 369 | } |
368 | 370 | err = sbjtcache_appenddata(cache, test_sbjtcache_testdata_01_2, strlen(test_sbjtcache_testdata_01_2)); |
369 | 371 | if (err < 0) { |
370 | 372 | printf("sbjtcache_appenddata error 2\n"); |
371 | 373 | sbjtcache_delete(cache); |
372 | - return TEST_RESULT_FAIL; | |
374 | + return UNITTEST_RESULT_FAIL; | |
373 | 375 | } |
374 | 376 | err = sbjtcache_appenddata(cache, test_sbjtcache_testdata_01_3, strlen(test_sbjtcache_testdata_01_3)); |
375 | 377 | if (err < 0) { |
376 | 378 | printf("sbjtcache_appenddata error 3\n"); |
377 | 379 | sbjtcache_delete(cache); |
378 | - return TEST_RESULT_FAIL; | |
380 | + return UNITTEST_RESULT_FAIL; | |
379 | 381 | } |
380 | 382 | err = sbjtcache_appenddata(cache, test_sbjtcache_testdata_01_4, strlen(test_sbjtcache_testdata_01_4)); |
381 | 383 | if (err < 0) { |
382 | 384 | printf("sbjtcache_appenddata error 4\n"); |
383 | 385 | sbjtcache_delete(cache); |
384 | - return TEST_RESULT_FAIL; | |
386 | + return UNITTEST_RESULT_FAIL; | |
385 | 387 | } |
386 | 388 | |
387 | 389 | context = sbjtcache_startdataread(cache, strlen(test_sbjtcache_testdata_01)+5); |
388 | 390 | if (context == NULL) { |
389 | 391 | sbjtcache_delete(cache); |
390 | - return TEST_RESULT_FAIL; | |
392 | + return UNITTEST_RESULT_FAIL; | |
391 | 393 | } |
392 | 394 | ok = sbjtcache_datareadcontext_nextdata(context, &bin_cache, &len_cache); |
393 | 395 | if (ok == True) { |
394 | - result = TEST_RESULT_FAIL; | |
396 | + result = UNITTEST_RESULT_FAIL; | |
395 | 397 | } |
396 | 398 | sbjtcache_enddataread(cache, context); |
397 | 399 |
@@ -400,35 +402,20 @@ | ||
400 | 402 | return result; |
401 | 403 | } |
402 | 404 | |
403 | -LOCAL TEST_RESULT test_sbjtcache_9() | |
405 | +LOCAL UNITTEST_RESULT test_sbjtcache_9() | |
404 | 406 | { |
405 | 407 | return test_sbjtcache_9_testseq(); |
406 | 408 | } |
407 | 409 | |
408 | -LOCAL VOID test_sbjtcache_printresult(TEST_RESULT (*proc)(), B *test_name) | |
410 | +EXPORT VOID test_sbjtcache_main(unittest_driver_t *driver) | |
409 | 411 | { |
410 | - TEST_RESULT result; | |
411 | - | |
412 | - printf("test_sbjtcache: %s\n", test_name); | |
413 | - printf("---------------------------------------------\n"); | |
414 | - result = proc(); | |
415 | - if (result == TEST_RESULT_PASS) { | |
416 | - printf("--pass---------------------------------------\n"); | |
417 | - } else { | |
418 | - printf("--fail---------------------------------------\n"); | |
419 | - } | |
420 | - printf("---------------------------------------------\n"); | |
412 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtcache_1); | |
413 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtcache_2); | |
414 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtcache_3); | |
415 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtcache_4); | |
416 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtcache_5); | |
417 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtcache_6); | |
418 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtcache_7); | |
419 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtcache_8); | |
420 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtcache_9); | |
421 | 421 | } |
422 | - | |
423 | -EXPORT VOID test_sbjtcache_main() | |
424 | -{ | |
425 | - test_sbjtcache_printresult(test_sbjtcache_1, "test_sbjtcache_1"); | |
426 | - test_sbjtcache_printresult(test_sbjtcache_2, "test_sbjtcache_2"); | |
427 | - test_sbjtcache_printresult(test_sbjtcache_3, "test_sbjtcache_3"); | |
428 | - test_sbjtcache_printresult(test_sbjtcache_4, "test_sbjtcache_4"); | |
429 | - test_sbjtcache_printresult(test_sbjtcache_5, "test_sbjtcache_5"); | |
430 | - test_sbjtcache_printresult(test_sbjtcache_6, "test_sbjtcache_6"); | |
431 | - test_sbjtcache_printresult(test_sbjtcache_7, "test_sbjtcache_7"); | |
432 | - test_sbjtcache_printresult(test_sbjtcache_8, "test_sbjtcache_8"); | |
433 | - test_sbjtcache_printresult(test_sbjtcache_9, "test_sbjtcache_9"); | |
434 | -} |
@@ -1,7 +1,7 @@ | ||
1 | 1 | /* |
2 | 2 | * test_bbsmenulayout.c |
3 | 3 | * |
4 | - * Copyright (c) 2009 project bchan | |
4 | + * Copyright (c) 2009-2012 project bchan | |
5 | 5 | * |
6 | 6 | * This software is provided 'as-is', without any express or implied |
7 | 7 | * warranty. In no event will the authors be held liable for any damages |
@@ -24,6 +24,10 @@ | ||
24 | 24 | * |
25 | 25 | */ |
26 | 26 | |
27 | +#include "test.h" | |
28 | + | |
29 | +#include "bbsmenulayout.h" | |
30 | + | |
27 | 31 | #include <btron/btron.h> |
28 | 32 | #include <btron/dp.h> |
29 | 33 | #include <tcode.h> |
@@ -31,9 +35,8 @@ | ||
31 | 35 | #include <bstring.h> |
32 | 36 | #include <bstdlib.h> |
33 | 37 | |
34 | -#include "test.h" | |
38 | +#include <unittest_driver.h> | |
35 | 39 | |
36 | -#include "bbsmenulayout.h" | |
37 | 40 | #include "bbsmenuparser.h" |
38 | 41 | #include "bbsmenucache.h" |
39 | 42 |
@@ -99,7 +102,7 @@ | ||
99 | 102 | free(bmp); |
100 | 103 | } |
101 | 104 | |
102 | -LOCAL TEST_RESULT test_bbsmnlayout_1() | |
105 | +LOCAL UNITTEST_RESULT test_bbsmnlayout_1() | |
103 | 106 | { |
104 | 107 | BMP *bmp; |
105 | 108 | GID gid; |
@@ -108,15 +111,15 @@ | ||
108 | 111 | bbsmncache_t *cache; |
109 | 112 | bbsmnparser_t *parser; |
110 | 113 | bbsmnparser_item_t *item = NULL; |
111 | - TEST_RESULT result = TEST_RESULT_PASS; | |
114 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
112 | 115 | |
113 | 116 | bmp = test_bbsmnlayout_util_alloc_BMP(); |
114 | 117 | if (bmp == NULL) { |
115 | - return TEST_RESULT_FAIL; | |
118 | + return UNITTEST_RESULT_FAIL; | |
116 | 119 | } |
117 | 120 | gid = gopn_mem(NULL, bmp, NULL); |
118 | 121 | if (gid < 0) { |
119 | - return TEST_RESULT_FAIL; | |
122 | + return UNITTEST_RESULT_FAIL; | |
120 | 123 | } |
121 | 124 | |
122 | 125 | cache = bbsmncache_new(); |
@@ -148,22 +151,7 @@ | ||
148 | 151 | return result; |
149 | 152 | } |
150 | 153 | |
151 | -LOCAL VOID test_bbsmnlayout_printresult(TEST_RESULT (*proc)(), B *test_name) | |
154 | +EXPORT VOID test_bbsmnlayout_main(unittest_driver_t *driver) | |
152 | 155 | { |
153 | - TEST_RESULT result; | |
154 | - | |
155 | - printf("test_bbsmnlayout: %s\n", test_name); | |
156 | - printf("---------------------------------------------\n"); | |
157 | - result = proc(); | |
158 | - if (result == TEST_RESULT_PASS) { | |
159 | - printf("--pass---------------------------------------\n"); | |
160 | - } else { | |
161 | - printf("--fail---------------------------------------\n"); | |
162 | - } | |
163 | - printf("---------------------------------------------\n"); | |
156 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnlayout_1); | |
164 | 157 | } |
165 | - | |
166 | -EXPORT VOID test_bbsmnlayout_main() | |
167 | -{ | |
168 | - test_bbsmnlayout_printresult(test_bbsmnlayout_1, "test_bbsmnlayout_1"); | |
169 | -} |
@@ -1,7 +1,7 @@ | ||
1 | 1 | /* |
2 | 2 | * test_bbsmenufilter.c |
3 | 3 | * |
4 | - * Copyright (c) 2010 project bchan | |
4 | + * Copyright (c) 2010-2012 project bchan | |
5 | 5 | * |
6 | 6 | * This software is provided 'as-is', without any express or implied |
7 | 7 | * warranty. In no event will the authors be held liable for any damages |
@@ -24,11 +24,14 @@ | ||
24 | 24 | * |
25 | 25 | */ |
26 | 26 | |
27 | +#include "test.h" | |
28 | + | |
29 | +#include "bbsmenufilter.h" | |
30 | + | |
27 | 31 | #include <bstdio.h> |
28 | 32 | |
29 | -#include "test.h" | |
33 | +#include <unittest_driver.h> | |
30 | 34 | |
31 | -#include "bbsmenufilter.h" | |
32 | 35 | #include "bbsmenuparser.h" |
33 | 36 | #include "bbsmenucache.h" |
34 | 37 |
@@ -69,7 +72,7 @@ | ||
69 | 72 | </BODY></HTML> |
70 | 73 | "}; |
71 | 74 | |
72 | -LOCAL TEST_RESULT test_bbsmnfilter_1() | |
75 | +LOCAL UNITTEST_RESULT test_bbsmnfilter_1() | |
73 | 76 | { |
74 | 77 | W ret,err; |
75 | 78 | bbsmncache_t *cache; |
@@ -76,7 +79,7 @@ | ||
76 | 79 | bbsmnparser_t *parser; |
77 | 80 | bbsmnparser_item_t *item = NULL; |
78 | 81 | bbsmnfilter_t *filter = NULL; |
79 | - TEST_RESULT result = TEST_RESULT_PASS; | |
82 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
80 | 83 | |
81 | 84 | cache = bbsmncache_new(); |
82 | 85 | bbsmncache_appenddata(cache, test_bbsmnfilter_testdata_01, strlen(test_bbsmnfilter_testdata_01)); |
@@ -120,13 +123,13 @@ | ||
120 | 123 | return result; |
121 | 124 | } |
122 | 125 | |
123 | -LOCAL TEST_RESULT test_bbsmnfilter_2_checkitem_index(bbsmnparser_item_t *item, W i) | |
126 | +LOCAL UNITTEST_RESULT test_bbsmnfilter_2_checkitem_index(bbsmnparser_item_t *item, W i) | |
124 | 127 | { |
125 | 128 | switch(i) { |
126 | 129 | case 0: |
127 | 130 | case 5: |
128 | 131 | if (item->category == NULL) { |
129 | - return TEST_RESULT_FAIL; | |
132 | + return UNITTEST_RESULT_FAIL; | |
130 | 133 | } |
131 | 134 | break; |
132 | 135 | case 1: |
@@ -138,17 +141,17 @@ | ||
138 | 141 | case 8: |
139 | 142 | case 9: |
140 | 143 | if ((item->category != NULL)||(item->url == NULL)||(item->title == NULL)) { |
141 | - return TEST_RESULT_FAIL; | |
144 | + return UNITTEST_RESULT_FAIL; | |
142 | 145 | } |
143 | 146 | break; |
144 | 147 | default: |
145 | - return TEST_RESULT_FAIL; | |
148 | + return UNITTEST_RESULT_FAIL; | |
146 | 149 | break; |
147 | 150 | } |
148 | - return TEST_RESULT_PASS; | |
151 | + return UNITTEST_RESULT_PASS; | |
149 | 152 | } |
150 | 153 | |
151 | -LOCAL TEST_RESULT test_bbsmnfilter_2() | |
154 | +LOCAL UNITTEST_RESULT test_bbsmnfilter_2() | |
152 | 155 | { |
153 | 156 | W i = 0, ret,err; |
154 | 157 | bbsmncache_t *cache; |
@@ -155,7 +158,7 @@ | ||
155 | 158 | bbsmnparser_t *parser; |
156 | 159 | bbsmnparser_item_t *item = NULL; |
157 | 160 | bbsmnfilter_t *filter = NULL; |
158 | - TEST_RESULT result = TEST_RESULT_PASS; | |
161 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
159 | 162 | |
160 | 163 | cache = bbsmncache_new(); |
161 | 164 | bbsmncache_appenddata(cache, test_bbsmnfilter_testdata_01, strlen(test_bbsmnfilter_testdata_01)); |
@@ -176,7 +179,7 @@ | ||
176 | 179 | i++; |
177 | 180 | bbsmnparser_item_delete(item); |
178 | 181 | |
179 | - if (result == TEST_RESULT_FAIL) { | |
182 | + if (result == UNITTEST_RESULT_FAIL) { | |
180 | 183 | printf("fail i = %d\n", i-1); |
181 | 184 | break; |
182 | 185 | } |
@@ -183,7 +186,7 @@ | ||
183 | 186 | } else { |
184 | 187 | if ((ret != BBSMNFILTER_OUTPUTITEM_WAITNEXT)&&(ret != BBSMNFILTER_OUTPUTITEM_END)) { |
185 | 188 | printf("invalid return value\n"); |
186 | - result = TEST_RESULT_FAIL; | |
189 | + result = UNITTEST_RESULT_FAIL; | |
187 | 190 | } |
188 | 191 | break; |
189 | 192 | } |
@@ -191,7 +194,7 @@ | ||
191 | 194 | break; |
192 | 195 | } |
193 | 196 | } |
194 | - if (result == TEST_RESULT_FAIL) { | |
197 | + if (result == UNITTEST_RESULT_FAIL) { | |
195 | 198 | break; |
196 | 199 | } |
197 | 200 | } |
@@ -204,7 +207,7 @@ | ||
204 | 207 | i++; |
205 | 208 | bbsmnparser_item_delete(item); |
206 | 209 | |
207 | - if (result == TEST_RESULT_FAIL) { | |
210 | + if (result == UNITTEST_RESULT_FAIL) { | |
208 | 211 | printf("fail i = %d\n", i-1); |
209 | 212 | break; |
210 | 213 | } |
@@ -215,12 +218,12 @@ | ||
215 | 218 | if (ret == BBSMNFILTER_OUTPUTITEM_END) { |
216 | 219 | break; |
217 | 220 | } |
218 | - result = TEST_RESULT_FAIL; | |
221 | + result = UNITTEST_RESULT_FAIL; | |
219 | 222 | printf("invalid return value\n"); |
220 | 223 | break; |
221 | 224 | } |
222 | 225 | if (i != 10) { |
223 | - result = TEST_RESULT_FAIL; | |
226 | + result = UNITTEST_RESULT_FAIL; | |
224 | 227 | printf("fail: too meny items\n"); |
225 | 228 | } |
226 | 229 |
@@ -232,23 +235,8 @@ | ||
232 | 235 | return result; |
233 | 236 | } |
234 | 237 | |
235 | -LOCAL VOID test_bbsmnfilter_printresult(TEST_RESULT (*proc)(), B *test_name) | |
238 | +EXPORT VOID test_bbsmnfilter_main(unittest_driver_t *driver) | |
236 | 239 | { |
237 | - TEST_RESULT result; | |
238 | - | |
239 | - printf("test_bbsmnfilter: %s\n", test_name); | |
240 | - printf("---------------------------------------------\n"); | |
241 | - result = proc(); | |
242 | - if (result == TEST_RESULT_PASS) { | |
243 | - printf("--pass---------------------------------------\n"); | |
244 | - } else { | |
245 | - printf("--fail---------------------------------------\n"); | |
246 | - } | |
247 | - printf("---------------------------------------------\n"); | |
240 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnfilter_1); | |
241 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnfilter_2); | |
248 | 242 | } |
249 | - | |
250 | -EXPORT VOID test_bbsmnfilter_main() | |
251 | -{ | |
252 | - test_bbsmnfilter_printresult(test_bbsmnfilter_1, "test_bbsmnfilter_1"); | |
253 | - test_bbsmnfilter_printresult(test_bbsmnfilter_2, "test_bbsmnfilter_2"); | |
254 | -} |
@@ -1,7 +1,7 @@ | ||
1 | 1 | /* |
2 | 2 | * test_bbsmenuparser.c |
3 | 3 | * |
4 | - * Copyright (c) 2009 project bchan | |
4 | + * Copyright (c) 2009-2012 project bchan | |
5 | 5 | * |
6 | 6 | * This software is provided 'as-is', without any express or implied |
7 | 7 | * warranty. In no event will the authors be held liable for any damages |
@@ -24,14 +24,17 @@ | ||
24 | 24 | * |
25 | 25 | */ |
26 | 26 | |
27 | +#include "test.h" | |
28 | + | |
29 | +#include "bbsmenuparser.h" | |
30 | + | |
27 | 31 | #include <btron/btron.h> |
28 | 32 | #include <tcode.h> |
29 | 33 | #include <bstdio.h> |
30 | 34 | #include <bstring.h> |
31 | 35 | |
32 | -#include "test.h" | |
36 | +#include <unittest_driver.h> | |
33 | 37 | |
34 | -#include "bbsmenuparser.h" | |
35 | 38 | #include "bbsmenucache.h" |
36 | 39 | |
37 | 40 | LOCAL UB test_bbsmnparser_testdata_01[] = { |
@@ -71,13 +74,13 @@ | ||
71 | 74 | </BODY></HTML> |
72 | 75 | "}; |
73 | 76 | |
74 | -LOCAL TEST_RESULT test_bbsmnparser_1() | |
77 | +LOCAL UNITTEST_RESULT test_bbsmnparser_1() | |
75 | 78 | { |
76 | 79 | W err; |
77 | 80 | bbsmncache_t *cache; |
78 | 81 | bbsmnparser_t *parser; |
79 | 82 | bbsmnparser_item_t *item = NULL; |
80 | - TEST_RESULT result = TEST_RESULT_PASS; | |
83 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
81 | 84 | |
82 | 85 | cache = bbsmncache_new(); |
83 | 86 | bbsmncache_appenddata(cache, test_bbsmnparser_testdata_01, strlen(test_bbsmnparser_testdata_01)); |
@@ -112,7 +115,7 @@ | ||
112 | 115 | return result; |
113 | 116 | } |
114 | 117 | |
115 | -LOCAL TEST_RESULT test_bbsmnparser_2() | |
118 | +LOCAL UNITTEST_RESULT test_bbsmnparser_2() | |
116 | 119 | { |
117 | 120 | bbsmnparser_item_t item; |
118 | 121 | Bool check; |
@@ -126,13 +129,13 @@ | ||
126 | 129 | |
127 | 130 | check = bbsmnparser_item_checkboradurl(&item); |
128 | 131 | if (check == False) { |
129 | - return TEST_RESULT_PASS; | |
132 | + return UNITTEST_RESULT_PASS; | |
130 | 133 | } |
131 | 134 | |
132 | - return TEST_RESULT_FAIL; | |
135 | + return UNITTEST_RESULT_FAIL; | |
133 | 136 | } |
134 | 137 | |
135 | -LOCAL TEST_RESULT test_bbsmnparser_3() | |
138 | +LOCAL UNITTEST_RESULT test_bbsmnparser_3() | |
136 | 139 | { |
137 | 140 | bbsmnparser_item_t item; |
138 | 141 | Bool check; |
@@ -146,13 +149,13 @@ | ||
146 | 149 | |
147 | 150 | check = bbsmnparser_item_checkboradurl(&item); |
148 | 151 | if (check == True) { |
149 | - return TEST_RESULT_PASS; | |
152 | + return UNITTEST_RESULT_PASS; | |
150 | 153 | } |
151 | 154 | |
152 | - return TEST_RESULT_FAIL; | |
155 | + return UNITTEST_RESULT_FAIL; | |
153 | 156 | } |
154 | 157 | |
155 | -LOCAL TEST_RESULT test_bbsmnparser_4() | |
158 | +LOCAL UNITTEST_RESULT test_bbsmnparser_4() | |
156 | 159 | { |
157 | 160 | bbsmnparser_item_t item; |
158 | 161 | Bool check; |
@@ -166,13 +169,13 @@ | ||
166 | 169 | |
167 | 170 | check = bbsmnparser_item_checkboradurl(&item); |
168 | 171 | if (check == False) { |
169 | - return TEST_RESULT_PASS; | |
172 | + return UNITTEST_RESULT_PASS; | |
170 | 173 | } |
171 | 174 | |
172 | - return TEST_RESULT_FAIL; | |
175 | + return UNITTEST_RESULT_FAIL; | |
173 | 176 | } |
174 | 177 | |
175 | -LOCAL TEST_RESULT test_bbsmnparser_5() | |
178 | +LOCAL UNITTEST_RESULT test_bbsmnparser_5() | |
176 | 179 | { |
177 | 180 | bbsmnparser_item_t item; |
178 | 181 | Bool check; |
@@ -186,13 +189,13 @@ | ||
186 | 189 | |
187 | 190 | check = bbsmnparser_item_checkboradurl(&item); |
188 | 191 | if (check == False) { |
189 | - return TEST_RESULT_PASS; | |
192 | + return UNITTEST_RESULT_PASS; | |
190 | 193 | } |
191 | 194 | |
192 | - return TEST_RESULT_FAIL; | |
195 | + return UNITTEST_RESULT_FAIL; | |
193 | 196 | } |
194 | 197 | |
195 | -LOCAL TEST_RESULT test_bbsmnparser_6() | |
198 | +LOCAL UNITTEST_RESULT test_bbsmnparser_6() | |
196 | 199 | { |
197 | 200 | bbsmnparser_item_t item; |
198 | 201 | Bool check; |
@@ -206,13 +209,13 @@ | ||
206 | 209 | |
207 | 210 | check = bbsmnparser_item_checkboradurl(&item); |
208 | 211 | if (check == False) { |
209 | - return TEST_RESULT_PASS; | |
212 | + return UNITTEST_RESULT_PASS; | |
210 | 213 | } |
211 | 214 | |
212 | - return TEST_RESULT_FAIL; | |
215 | + return UNITTEST_RESULT_FAIL; | |
213 | 216 | } |
214 | 217 | |
215 | -LOCAL TEST_RESULT test_bbsmnparser_7() | |
218 | +LOCAL UNITTEST_RESULT test_bbsmnparser_7() | |
216 | 219 | { |
217 | 220 | bbsmnparser_item_t item; |
218 | 221 | Bool check; |
@@ -226,13 +229,13 @@ | ||
226 | 229 | |
227 | 230 | check = bbsmnparser_item_checkboradurl(&item); |
228 | 231 | if (check == False) { |
229 | - return TEST_RESULT_PASS; | |
232 | + return UNITTEST_RESULT_PASS; | |
230 | 233 | } |
231 | 234 | |
232 | - return TEST_RESULT_FAIL; | |
235 | + return UNITTEST_RESULT_FAIL; | |
233 | 236 | } |
234 | 237 | |
235 | -LOCAL TEST_RESULT test_bbsmnparser_8() | |
238 | +LOCAL UNITTEST_RESULT test_bbsmnparser_8() | |
236 | 239 | { |
237 | 240 | bbsmnparser_item_t item; |
238 | 241 | Bool check; |
@@ -246,13 +249,13 @@ | ||
246 | 249 | |
247 | 250 | check = bbsmnparser_item_checkboradurl(&item); |
248 | 251 | if (check == True) { |
249 | - return TEST_RESULT_PASS; | |
252 | + return UNITTEST_RESULT_PASS; | |
250 | 253 | } |
251 | 254 | |
252 | - return TEST_RESULT_FAIL; | |
255 | + return UNITTEST_RESULT_FAIL; | |
253 | 256 | } |
254 | 257 | |
255 | -LOCAL TEST_RESULT test_bbsmnparser_9() | |
258 | +LOCAL UNITTEST_RESULT test_bbsmnparser_9() | |
256 | 259 | { |
257 | 260 | bbsmnparser_item_t item; |
258 | 261 | Bool check; |
@@ -266,13 +269,13 @@ | ||
266 | 269 | |
267 | 270 | check = bbsmnparser_item_checkboradurl(&item); |
268 | 271 | if (check == False) { |
269 | - return TEST_RESULT_PASS; | |
272 | + return UNITTEST_RESULT_PASS; | |
270 | 273 | } |
271 | 274 | |
272 | - return TEST_RESULT_FAIL; | |
275 | + return UNITTEST_RESULT_FAIL; | |
273 | 276 | } |
274 | 277 | |
275 | -LOCAL TEST_RESULT test_bbsmnparser_10() | |
278 | +LOCAL UNITTEST_RESULT test_bbsmnparser_10() | |
276 | 279 | { |
277 | 280 | bbsmnparser_item_t item; |
278 | 281 | Bool check; |
@@ -286,13 +289,13 @@ | ||
286 | 289 | |
287 | 290 | check = bbsmnparser_item_checkboradurl(&item); |
288 | 291 | if (check == False) { |
289 | - return TEST_RESULT_PASS; | |
292 | + return UNITTEST_RESULT_PASS; | |
290 | 293 | } |
291 | 294 | |
292 | - return TEST_RESULT_FAIL; | |
295 | + return UNITTEST_RESULT_FAIL; | |
293 | 296 | } |
294 | 297 | |
295 | -LOCAL TEST_RESULT test_bbsmnparser_11() | |
298 | +LOCAL UNITTEST_RESULT test_bbsmnparser_11() | |
296 | 299 | { |
297 | 300 | bbsmnparser_item_t item; |
298 | 301 | Bool check; |
@@ -306,13 +309,13 @@ | ||
306 | 309 | |
307 | 310 | check = bbsmnparser_item_checkboradurl(&item); |
308 | 311 | if (check == False) { |
309 | - return TEST_RESULT_PASS; | |
312 | + return UNITTEST_RESULT_PASS; | |
310 | 313 | } |
311 | 314 | |
312 | - return TEST_RESULT_FAIL; | |
315 | + return UNITTEST_RESULT_FAIL; | |
313 | 316 | } |
314 | 317 | |
315 | -LOCAL TEST_RESULT test_bbsmnparser_12() | |
318 | +LOCAL UNITTEST_RESULT test_bbsmnparser_12() | |
316 | 319 | { |
317 | 320 | bbsmnparser_item_t item; |
318 | 321 | Bool check; |
@@ -326,13 +329,13 @@ | ||
326 | 329 | |
327 | 330 | check = bbsmnparser_item_checkboradurl(&item); |
328 | 331 | if (check == False) { |
329 | - return TEST_RESULT_PASS; | |
332 | + return UNITTEST_RESULT_PASS; | |
330 | 333 | } |
331 | 334 | |
332 | - return TEST_RESULT_FAIL; | |
335 | + return UNITTEST_RESULT_FAIL; | |
333 | 336 | } |
334 | 337 | |
335 | -LOCAL TEST_RESULT test_bbsmnparser_13() | |
338 | +LOCAL UNITTEST_RESULT test_bbsmnparser_13() | |
336 | 339 | { |
337 | 340 | bbsmnparser_item_t item; |
338 | 341 | Bool check; |
@@ -346,13 +349,13 @@ | ||
346 | 349 | |
347 | 350 | check = bbsmnparser_item_checkboradurl(&item); |
348 | 351 | if (check == False) { |
349 | - return TEST_RESULT_PASS; | |
352 | + return UNITTEST_RESULT_PASS; | |
350 | 353 | } |
351 | 354 | |
352 | - return TEST_RESULT_FAIL; | |
355 | + return UNITTEST_RESULT_FAIL; | |
353 | 356 | } |
354 | 357 | |
355 | -LOCAL TEST_RESULT test_bbsmnparser_14() | |
358 | +LOCAL UNITTEST_RESULT test_bbsmnparser_14() | |
356 | 359 | { |
357 | 360 | bbsmnparser_item_t item; |
358 | 361 | Bool check; |
@@ -366,13 +369,13 @@ | ||
366 | 369 | |
367 | 370 | check = bbsmnparser_item_checkboradurl(&item); |
368 | 371 | if (check == False) { |
369 | - return TEST_RESULT_PASS; | |
372 | + return UNITTEST_RESULT_PASS; | |
370 | 373 | } |
371 | 374 | |
372 | - return TEST_RESULT_FAIL; | |
375 | + return UNITTEST_RESULT_FAIL; | |
373 | 376 | } |
374 | 377 | |
375 | -LOCAL TEST_RESULT test_bbsmnparser_15() | |
378 | +LOCAL UNITTEST_RESULT test_bbsmnparser_15() | |
376 | 379 | { |
377 | 380 | bbsmnparser_item_t item; |
378 | 381 | Bool check; |
@@ -386,42 +389,27 @@ | ||
386 | 389 | |
387 | 390 | check = bbsmnparser_item_checkboradurl(&item); |
388 | 391 | if (check == False) { |
389 | - return TEST_RESULT_PASS; | |
392 | + return UNITTEST_RESULT_PASS; | |
390 | 393 | } |
391 | 394 | |
392 | - return TEST_RESULT_FAIL; | |
395 | + return UNITTEST_RESULT_FAIL; | |
393 | 396 | } |
394 | 397 | |
395 | -LOCAL VOID test_bbsmnparser_printresult(TEST_RESULT (*proc)(), B *test_name) | |
398 | +EXPORT VOID test_bbsmnparser_main(unittest_driver_t *driver) | |
396 | 399 | { |
397 | - TEST_RESULT result; | |
398 | - | |
399 | - printf("test_bbsmnparser: %s\n", test_name); | |
400 | - printf("---------------------------------------------\n"); | |
401 | - result = proc(); | |
402 | - if (result == TEST_RESULT_PASS) { | |
403 | - printf("--pass---------------------------------------\n"); | |
404 | - } else { | |
405 | - printf("--fail---------------------------------------\n"); | |
406 | - } | |
407 | - printf("---------------------------------------------\n"); | |
400 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnparser_1); | |
401 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnparser_2); | |
402 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnparser_3); | |
403 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnparser_4); | |
404 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnparser_5); | |
405 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnparser_6); | |
406 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnparser_7); | |
407 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnparser_8); | |
408 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnparser_9); | |
409 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnparser_10); | |
410 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnparser_11); | |
411 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnparser_12); | |
412 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnparser_13); | |
413 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnparser_14); | |
414 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmnparser_15); | |
408 | 415 | } |
409 | - | |
410 | -EXPORT VOID test_bbsmnparser_main() | |
411 | -{ | |
412 | - test_bbsmnparser_printresult(test_bbsmnparser_1, "test_bbsmnparser_1"); | |
413 | - test_bbsmnparser_printresult(test_bbsmnparser_2, "test_bbsmnparser_2"); | |
414 | - test_bbsmnparser_printresult(test_bbsmnparser_3, "test_bbsmnparser_3"); | |
415 | - test_bbsmnparser_printresult(test_bbsmnparser_4, "test_bbsmnparser_4"); | |
416 | - test_bbsmnparser_printresult(test_bbsmnparser_5, "test_bbsmnparser_5"); | |
417 | - test_bbsmnparser_printresult(test_bbsmnparser_6, "test_bbsmnparser_6"); | |
418 | - test_bbsmnparser_printresult(test_bbsmnparser_7, "test_bbsmnparser_7"); | |
419 | - test_bbsmnparser_printresult(test_bbsmnparser_8, "test_bbsmnparser_8"); | |
420 | - test_bbsmnparser_printresult(test_bbsmnparser_9, "test_bbsmnparser_9"); | |
421 | - test_bbsmnparser_printresult(test_bbsmnparser_10, "test_bbsmnparser_10"); | |
422 | - test_bbsmnparser_printresult(test_bbsmnparser_11, "test_bbsmnparser_11"); | |
423 | - test_bbsmnparser_printresult(test_bbsmnparser_12, "test_bbsmnparser_12"); | |
424 | - test_bbsmnparser_printresult(test_bbsmnparser_13, "test_bbsmnparser_13"); | |
425 | - test_bbsmnparser_printresult(test_bbsmnparser_14, "test_bbsmnparser_14"); | |
426 | - test_bbsmnparser_printresult(test_bbsmnparser_15, "test_bbsmnparser_15"); | |
427 | -} |
@@ -1,7 +1,7 @@ | ||
1 | 1 | /* |
2 | 2 | * test_bbsmenucache.c |
3 | 3 | * |
4 | - * Copyright (c) 2009 project bchan | |
4 | + * Copyright (c) 2009-2012 project bchan | |
5 | 5 | * |
6 | 6 | * This software is provided 'as-is', without any express or implied |
7 | 7 | * warranty. In no event will the authors be held liable for any damages |
@@ -24,6 +24,10 @@ | ||
24 | 24 | * |
25 | 25 | */ |
26 | 26 | |
27 | +#include "test.h" | |
28 | + | |
29 | +#include "bbsmenucache.h" | |
30 | + | |
27 | 31 | #include <btron/btron.h> |
28 | 32 | #include <tcode.h> |
29 | 33 | #include <bstdio.h> |
@@ -31,10 +35,8 @@ | ||
31 | 35 | #include <bstdlib.h> |
32 | 36 | #include <errcode.h> |
33 | 37 | |
34 | -#include "test.h" | |
38 | +#include <unittest_driver.h> | |
35 | 39 | |
36 | -#include "bbsmenucache.h" | |
37 | - | |
38 | 40 | LOCAL UB test_bbsmncache_testdata_01[] = {"aaaaabbbbbcccccddddd"}; |
39 | 41 | LOCAL UB test_bbsmncache_testdata_01_1[] = {"aaaaa"}; |
40 | 42 | LOCAL UB test_bbsmncache_testdata_01_2[] = {"bbbbb"}; |
@@ -73,10 +75,10 @@ | ||
73 | 75 | |
74 | 76 | /* test_bbsmncache_1 */ |
75 | 77 | |
76 | -LOCAL TEST_RESULT test_bbsmncache_1_testseq() | |
78 | +LOCAL UNITTEST_RESULT test_bbsmncache_1_testseq() | |
77 | 79 | { |
78 | 80 | bbsmncache_t *cache; |
79 | - TEST_RESULT result = TEST_RESULT_PASS; | |
81 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
80 | 82 | UB *header; |
81 | 83 | W err, header_len, cmp; |
82 | 84 |
@@ -86,18 +88,18 @@ | ||
86 | 88 | if (err < 0) { |
87 | 89 | printf("bbsmncache_updatelataestheade error\n"); |
88 | 90 | bbsmncache_delete(cache); |
89 | - return TEST_RESULT_FAIL; | |
91 | + return UNITTEST_RESULT_FAIL; | |
90 | 92 | } |
91 | 93 | |
92 | 94 | bbsmncache_getlatestheader(cache, &header, &header_len); |
93 | 95 | if (header_len != strlen(test_bbsmncache_testdata_07)) { |
94 | 96 | printf("bbsmncache_getlatestheader: length error\n"); |
95 | - result = TEST_RESULT_FAIL; | |
97 | + result = UNITTEST_RESULT_FAIL; | |
96 | 98 | } |
97 | 99 | cmp = memcmp(header, test_bbsmncache_testdata_07, header_len); |
98 | 100 | if (cmp != 0) { |
99 | 101 | printf("bbsmncache_getlatestheader: data error\n"); |
100 | - result = TEST_RESULT_FAIL; | |
102 | + result = UNITTEST_RESULT_FAIL; | |
101 | 103 | } |
102 | 104 | |
103 | 105 | bbsmncache_delete(cache); |
@@ -105,7 +107,7 @@ | ||
105 | 107 | return result; |
106 | 108 | } |
107 | 109 | |
108 | -LOCAL TEST_RESULT test_bbsmncache_1() | |
110 | +LOCAL UNITTEST_RESULT test_bbsmncache_1() | |
109 | 111 | { |
110 | 112 | return test_bbsmncache_1_testseq(); |
111 | 113 | } |
@@ -112,10 +114,10 @@ | ||
112 | 114 | |
113 | 115 | /* test_bbsmncache_2 */ |
114 | 116 | |
115 | -LOCAL TEST_RESULT test_bbsmncache_2_testseq() | |
117 | +LOCAL UNITTEST_RESULT test_bbsmncache_2_testseq() | |
116 | 118 | { |
117 | 119 | bbsmncache_t *cache; |
118 | - TEST_RESULT result = TEST_RESULT_PASS; | |
120 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
119 | 121 | UB *header; |
120 | 122 | W err, header_len, cmp; |
121 | 123 |
@@ -125,24 +127,24 @@ | ||
125 | 127 | if (err < 0) { |
126 | 128 | printf("bbsmncache_updatelataestheade error\n"); |
127 | 129 | bbsmncache_delete(cache); |
128 | - return TEST_RESULT_FAIL; | |
130 | + return UNITTEST_RESULT_FAIL; | |
129 | 131 | } |
130 | 132 | err = bbsmncache_updatelatestheader(cache, test_bbsmncache_testdata_02, strlen(test_bbsmncache_testdata_02)); |
131 | 133 | if (err < 0) { |
132 | 134 | printf("bbsmncache_updatelataestheade error\n"); |
133 | 135 | bbsmncache_delete(cache); |
134 | - return TEST_RESULT_FAIL; | |
136 | + return UNITTEST_RESULT_FAIL; | |
135 | 137 | } |
136 | 138 | |
137 | 139 | bbsmncache_getlatestheader(cache, &header, &header_len); |
138 | 140 | if (header_len != strlen(test_bbsmncache_testdata_02)) { |
139 | 141 | printf("bbsmncache_getlatestheader: length error\n"); |
140 | - result = TEST_RESULT_FAIL; | |
142 | + result = UNITTEST_RESULT_FAIL; | |
141 | 143 | } |
142 | 144 | cmp = memcmp(header, test_bbsmncache_testdata_02, header_len); |
143 | 145 | if (cmp != 0) { |
144 | 146 | printf("bbsmncache_getlatestheader: data error\n"); |
145 | - result = TEST_RESULT_FAIL; | |
147 | + result = UNITTEST_RESULT_FAIL; | |
146 | 148 | } |
147 | 149 | |
148 | 150 | bbsmncache_delete(cache); |
@@ -150,7 +152,7 @@ | ||
150 | 152 | return result; |
151 | 153 | } |
152 | 154 | |
153 | -LOCAL TEST_RESULT test_bbsmncache_2() | |
155 | +LOCAL UNITTEST_RESULT test_bbsmncache_2() | |
154 | 156 | { |
155 | 157 | return test_bbsmncache_2_testseq(); |
156 | 158 | } |
@@ -157,10 +159,10 @@ | ||
157 | 159 | |
158 | 160 | /* test_bbsmncache_3 */ |
159 | 161 | |
160 | -LOCAL TEST_RESULT test_bbsmncache_3_testseq() | |
162 | +LOCAL UNITTEST_RESULT test_bbsmncache_3_testseq() | |
161 | 163 | { |
162 | 164 | bbsmncache_t *cache; |
163 | - TEST_RESULT result = TEST_RESULT_PASS; | |
165 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
164 | 166 | UB *header; |
165 | 167 | W header_len; |
166 | 168 |
@@ -169,11 +171,11 @@ | ||
169 | 171 | bbsmncache_getlatestheader(cache, &header, &header_len); |
170 | 172 | if (header != NULL) { |
171 | 173 | printf("bbsmncache_getlatestheader: data error\n"); |
172 | - result = TEST_RESULT_FAIL; | |
174 | + result = UNITTEST_RESULT_FAIL; | |
173 | 175 | } |
174 | 176 | if (header_len != 0) { |
175 | 177 | printf("bbsmncache_getlatestheader: length error\n"); |
176 | - result = TEST_RESULT_FAIL; | |
178 | + result = UNITTEST_RESULT_FAIL; | |
177 | 179 | } |
178 | 180 | |
179 | 181 | bbsmncache_delete(cache); |
@@ -181,7 +183,7 @@ | ||
181 | 183 | return result; |
182 | 184 | } |
183 | 185 | |
184 | -LOCAL TEST_RESULT test_bbsmncache_3() | |
186 | +LOCAL UNITTEST_RESULT test_bbsmncache_3() | |
185 | 187 | { |
186 | 188 | return test_bbsmncache_3_testseq(); |
187 | 189 | } |
@@ -188,12 +190,12 @@ | ||
188 | 190 | |
189 | 191 | /* test_bbsmncache_4 */ |
190 | 192 | |
191 | -LOCAL TEST_RESULT test_bbsmncache_4_testseq() | |
193 | +LOCAL UNITTEST_RESULT test_bbsmncache_4_testseq() | |
192 | 194 | { |
193 | 195 | W err; |
194 | 196 | bbsmncache_t *cache; |
195 | 197 | bbsmncache_datareadcontext_t *context; |
196 | - TEST_RESULT result = TEST_RESULT_PASS; | |
198 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
197 | 199 | Bool ok; |
198 | 200 | |
199 | 201 | cache = bbsmncache_new(); |
@@ -202,25 +204,25 @@ | ||
202 | 204 | if (err < 0) { |
203 | 205 | printf("bbsmncache_appenddata error 1\n"); |
204 | 206 | bbsmncache_delete(cache); |
205 | - return TEST_RESULT_FAIL; | |
207 | + return UNITTEST_RESULT_FAIL; | |
206 | 208 | } |
207 | 209 | err = bbsmncache_appenddata(cache, test_bbsmncache_testdata_01_2, strlen(test_bbsmncache_testdata_01_2)); |
208 | 210 | if (err < 0) { |
209 | 211 | printf("bbsmncache_appenddata error 2\n"); |
210 | 212 | bbsmncache_delete(cache); |
211 | - return TEST_RESULT_FAIL; | |
213 | + return UNITTEST_RESULT_FAIL; | |
212 | 214 | } |
213 | 215 | err = bbsmncache_appenddata(cache, test_bbsmncache_testdata_01_3, strlen(test_bbsmncache_testdata_01_3)); |
214 | 216 | if (err < 0) { |
215 | 217 | printf("bbsmncache_appenddata error 3\n"); |
216 | 218 | bbsmncache_delete(cache); |
217 | - return TEST_RESULT_FAIL; | |
219 | + return UNITTEST_RESULT_FAIL; | |
218 | 220 | } |
219 | 221 | err = bbsmncache_appenddata(cache, test_bbsmncache_testdata_01_4, strlen(test_bbsmncache_testdata_01_4)); |
220 | 222 | if (err < 0) { |
221 | 223 | printf("bbsmncache_appenddata error 4\n"); |
222 | 224 | bbsmncache_delete(cache); |
223 | - return TEST_RESULT_FAIL; | |
225 | + return UNITTEST_RESULT_FAIL; | |
224 | 226 | } |
225 | 227 | |
226 | 228 | context = bbsmncache_startdataread(cache, 0); |
@@ -227,11 +229,11 @@ | ||
227 | 229 | if (context == NULL) { |
228 | 230 | printf("bbsmncache_startdataread error\n"); |
229 | 231 | bbsmncache_delete(cache); |
230 | - return TEST_RESULT_FAIL; | |
232 | + return UNITTEST_RESULT_FAIL; | |
231 | 233 | } |
232 | 234 | ok = test_bbsmncache_util_cmp_ctx_str(context, test_bbsmncache_testdata_01, strlen(test_bbsmncache_testdata_01)); |
233 | 235 | if (ok != True) { |
234 | - result = TEST_RESULT_FAIL; | |
236 | + result = UNITTEST_RESULT_FAIL; | |
235 | 237 | } |
236 | 238 | bbsmncache_enddataread(cache, context); |
237 | 239 |
@@ -240,7 +242,7 @@ | ||
240 | 242 | return result; |
241 | 243 | } |
242 | 244 | |
243 | -LOCAL TEST_RESULT test_bbsmncache_4() | |
245 | +LOCAL UNITTEST_RESULT test_bbsmncache_4() | |
244 | 246 | { |
245 | 247 | return test_bbsmncache_4_testseq(); |
246 | 248 | } |
@@ -247,12 +249,12 @@ | ||
247 | 249 | |
248 | 250 | /* test_bbsmncache_5 */ |
249 | 251 | |
250 | -LOCAL TEST_RESULT test_bbsmncache_5_testseq() | |
252 | +LOCAL UNITTEST_RESULT test_bbsmncache_5_testseq() | |
251 | 253 | { |
252 | 254 | W err; |
253 | 255 | bbsmncache_t *cache; |
254 | 256 | bbsmncache_datareadcontext_t *context; |
255 | - TEST_RESULT result = TEST_RESULT_PASS; | |
257 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
256 | 258 | UB *bin_cache; |
257 | 259 | W len_cache; |
258 | 260 | Bool ok; |
@@ -263,35 +265,35 @@ | ||
263 | 265 | if (err < 0) { |
264 | 266 | printf("bbsmncache_appenddata error 1\n"); |
265 | 267 | bbsmncache_delete(cache); |
266 | - return TEST_RESULT_FAIL; | |
268 | + return UNITTEST_RESULT_FAIL; | |
267 | 269 | } |
268 | 270 | err = bbsmncache_appenddata(cache, test_bbsmncache_testdata_01_2, strlen(test_bbsmncache_testdata_01_2)); |
269 | 271 | if (err < 0) { |
270 | 272 | printf("bbsmncache_appenddata error 2\n"); |
271 | 273 | bbsmncache_delete(cache); |
272 | - return TEST_RESULT_FAIL; | |
274 | + return UNITTEST_RESULT_FAIL; | |
273 | 275 | } |
274 | 276 | err = bbsmncache_appenddata(cache, test_bbsmncache_testdata_01_3, strlen(test_bbsmncache_testdata_01_3)); |
275 | 277 | if (err < 0) { |
276 | 278 | printf("bbsmncache_appenddata error 3\n"); |
277 | 279 | bbsmncache_delete(cache); |
278 | - return TEST_RESULT_FAIL; | |
280 | + return UNITTEST_RESULT_FAIL; | |
279 | 281 | } |
280 | 282 | err = bbsmncache_appenddata(cache, test_bbsmncache_testdata_01_4, strlen(test_bbsmncache_testdata_01_4)); |
281 | 283 | if (err < 0) { |
282 | 284 | printf("bbsmncache_appenddata error 4\n"); |
283 | 285 | bbsmncache_delete(cache); |
284 | - return TEST_RESULT_FAIL; | |
286 | + return UNITTEST_RESULT_FAIL; | |
285 | 287 | } |
286 | 288 | |
287 | 289 | context = bbsmncache_startdataread(cache, strlen(test_bbsmncache_testdata_01)+5); |
288 | 290 | if (context == NULL) { |
289 | 291 | bbsmncache_delete(cache); |
290 | - return TEST_RESULT_FAIL; | |
292 | + return UNITTEST_RESULT_FAIL; | |
291 | 293 | } |
292 | 294 | ok = bbsmncache_datareadcontext_nextdata(context, &bin_cache, &len_cache); |
293 | 295 | if (ok == True) { |
294 | - result = TEST_RESULT_FAIL; | |
296 | + result = UNITTEST_RESULT_FAIL; | |
295 | 297 | } |
296 | 298 | bbsmncache_enddataread(cache, context); |
297 | 299 |
@@ -300,31 +302,16 @@ | ||
300 | 302 | return result; |
301 | 303 | } |
302 | 304 | |
303 | -LOCAL TEST_RESULT test_bbsmncache_5() | |
305 | +LOCAL UNITTEST_RESULT test_bbsmncache_5() | |
304 | 306 | { |
305 | 307 | return test_bbsmncache_5_testseq(); |
306 | 308 | } |
307 | 309 | |
308 | -LOCAL VOID test_bbsmncache_printresult(TEST_RESULT (*proc)(), B *test_name) | |
310 | +EXPORT VOID test_bbsmncache_main(unittest_driver_t *driver) | |
309 | 311 | { |
310 | - TEST_RESULT result; | |
311 | - | |
312 | - printf("test_bbsmncache: %s\n", test_name); | |
313 | - printf("---------------------------------------------\n"); | |
314 | - result = proc(); | |
315 | - if (result == TEST_RESULT_PASS) { | |
316 | - printf("--pass---------------------------------------\n"); | |
317 | - } else { | |
318 | - printf("--fail---------------------------------------\n"); | |
319 | - } | |
320 | - printf("---------------------------------------------\n"); | |
312 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmncache_1); | |
313 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmncache_2); | |
314 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmncache_3); | |
315 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmncache_4); | |
316 | + UNITTEST_DRIVER_REGIST(driver, test_bbsmncache_5); | |
321 | 317 | } |
322 | - | |
323 | -EXPORT VOID test_bbsmncache_main() | |
324 | -{ | |
325 | - test_bbsmncache_printresult(test_bbsmncache_1, "test_bbsmncache_1"); | |
326 | - test_bbsmncache_printresult(test_bbsmncache_2, "test_bbsmncache_2"); | |
327 | - test_bbsmncache_printresult(test_bbsmncache_3, "test_bbsmncache_3"); | |
328 | - test_bbsmncache_printresult(test_bbsmncache_4, "test_bbsmncache_4"); | |
329 | - test_bbsmncache_printresult(test_bbsmncache_5, "test_bbsmncache_5"); | |
330 | -} |
@@ -27,18 +27,32 @@ | ||
27 | 27 | #include <basic.h> |
28 | 28 | #include <btron/btron.h> |
29 | 29 | |
30 | +#include <unittest_driver.h> | |
31 | + | |
30 | 32 | #include "test.h" |
31 | 33 | |
32 | 34 | EXPORT W MAIN(MESSAGE *msg) |
33 | 35 | { |
34 | - test_sbjtcache_main(); | |
35 | - test_sbjtparser_main(); | |
36 | - test_sbjtlist_main(); | |
37 | - test_sbjtlayout_main(); | |
38 | - test_bbsmncache_main(); | |
39 | - test_bbsmnparser_main(); | |
40 | - test_bbsmnlayout_main(); | |
41 | - test_bbsmnfilter_main(); | |
36 | + unittest_driver_t *driver; | |
42 | 37 | |
38 | + malloctest(-2); | |
39 | + | |
40 | + driver = unittest_driver_new(); | |
41 | + if (driver == NULL) { | |
42 | + return 0; | |
43 | + } | |
44 | + | |
45 | + test_sbjtcache_main(driver); | |
46 | + test_sbjtparser_main(driver); | |
47 | + test_sbjtlist_main(driver); | |
48 | + test_sbjtlayout_main(driver); | |
49 | + test_bbsmncache_main(driver); | |
50 | + test_bbsmnparser_main(driver); | |
51 | + test_bbsmnlayout_main(driver); | |
52 | + test_bbsmnfilter_main(driver); | |
53 | + | |
54 | + unittest_driver_runnning(driver); | |
55 | + unittest_driver_delete(driver); | |
56 | + | |
43 | 57 | return 0; |
44 | 58 | } |
@@ -25,37 +25,33 @@ | ||
25 | 25 | */ |
26 | 26 | |
27 | 27 | #include <basic.h> |
28 | +#include <unittest_driver.h> | |
28 | 29 | |
29 | 30 | #ifndef __BCHANL_TEST_H__ |
30 | 31 | #define __BCHANL_TEST_H__ |
31 | 32 | |
32 | -typedef enum { | |
33 | - TEST_RESULT_PASS, | |
34 | - TEST_RESULT_FAIL | |
35 | -} TEST_RESULT; | |
36 | - | |
37 | 33 | /* test_subjectcache.c */ |
38 | -IMPORT VOID test_sbjtcache_main(); | |
34 | +IMPORT VOID test_sbjtcache_main(unittest_driver_t *driver); | |
39 | 35 | |
40 | 36 | /* test_subjectparser.c */ |
41 | -IMPORT VOID test_sbjtparser_main(); | |
37 | +IMPORT VOID test_sbjtparser_main(unittest_driver_t *driver); | |
42 | 38 | |
43 | 39 | /* test_subjectlist.c */ |
44 | -IMPORT VOID test_sbjtlist_main(); | |
40 | +IMPORT VOID test_sbjtlist_main(unittest_driver_t *driver); | |
45 | 41 | |
46 | 42 | /* test_subjectlayout.c */ |
47 | -IMPORT VOID test_sbjtlayout_main(); | |
43 | +IMPORT VOID test_sbjtlayout_main(unittest_driver_t *driver); | |
48 | 44 | |
49 | 45 | /* test_bbsmenucache.c */ |
50 | -IMPORT VOID test_bbsmncache_main(); | |
46 | +IMPORT VOID test_bbsmncache_main(unittest_driver_t *driver); | |
51 | 47 | |
52 | 48 | /* test_bbsmenuparser.c */ |
53 | -IMPORT VOID test_bbsmnparser_main(); | |
49 | +IMPORT VOID test_bbsmnparser_main(unittest_driver_t *driver); | |
54 | 50 | |
55 | 51 | /* test_bbsmenulayout.c */ |
56 | -IMPORT VOID test_bbsmnlayout_main(); | |
52 | +IMPORT VOID test_bbsmnlayout_main(unittest_driver_t *driver); | |
57 | 53 | |
58 | 54 | /* test_bbsmenufilter.c */ |
59 | -IMPORT VOID test_bbsmnfilter_main(); | |
55 | +IMPORT VOID test_bbsmnfilter_main(unittest_driver_t *driver); | |
60 | 56 | |
61 | 57 | #endif |
@@ -1,7 +1,7 @@ | ||
1 | 1 | /* |
2 | 2 | * test_subjectlist.c |
3 | 3 | * |
4 | - * Copyright (c) 2011 project bchan | |
4 | + * Copyright (c) 2011-2012 project bchan | |
5 | 5 | * |
6 | 6 | * This software is provided 'as-is', without any express or implied |
7 | 7 | * warranty. In no event will the authors be held liable for any damages |
@@ -24,6 +24,10 @@ | ||
24 | 24 | * |
25 | 25 | */ |
26 | 26 | |
27 | +#include "test.h" | |
28 | + | |
29 | +#include "subjectlist.h" | |
30 | + | |
27 | 31 | #include <btron/btron.h> |
28 | 32 | #include <btron/dp.h> |
29 | 33 | #include <tcode.h> |
@@ -32,9 +36,8 @@ | ||
32 | 36 | #include <bstdlib.h> |
33 | 37 | #include <tstring.h> |
34 | 38 | |
35 | -#include "test.h" | |
39 | +#include <unittest_driver.h> | |
36 | 40 | |
37 | -#include "subjectlist.h" | |
38 | 41 | #include "subjectparser.h" |
39 | 42 | #include "subjectcache.h" |
40 | 43 |
@@ -83,7 +86,7 @@ | ||
83 | 86 | }; |
84 | 87 | typedef struct testsbjtlist_expected_t_ testsbjtlist_expected_t; |
85 | 88 | |
86 | -LOCAL TEST_RESULT test_sbjtlist_checksort(UB *testdata, W testdata_len, W sortby, Bool descendant, TC *filterword, W filterword_len, testsbjtlist_expected_t *expected, W expected_len) | |
89 | +LOCAL UNITTEST_RESULT test_sbjtlist_checksort(UB *testdata, W testdata_len, W sortby, Bool descendant, TC *filterword, W filterword_len, testsbjtlist_expected_t *expected, W expected_len) | |
87 | 90 | { |
88 | 91 | W err, num, len, i; |
89 | 92 | Bool next; |
@@ -94,7 +97,7 @@ | ||
94 | 97 | sbjtcache_t *cache; |
95 | 98 | sbjtparser_t *parser; |
96 | 99 | sbjtparser_thread_t *thread = NULL; |
97 | - TEST_RESULT result = TEST_RESULT_PASS; | |
100 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
98 | 101 | |
99 | 102 | cache = sbjtcache_new(); |
100 | 103 | sbjtcache_appenddata(cache, testdata, testdata_len); |
@@ -123,28 +126,28 @@ | ||
123 | 126 | break; |
124 | 127 | } |
125 | 128 | if (i >= expected_len) { |
126 | - result = TEST_RESULT_FAIL; | |
129 | + result = UNITTEST_RESULT_FAIL; | |
127 | 130 | break; |
128 | 131 | } |
129 | 132 | sbjtlist_tuple_gettitle(tuple, &title, &len); |
130 | 133 | sbjtlist_tuple_getnumber(tuple, &num); |
131 | 134 | if (expected[i].num != num) { |
132 | - result = TEST_RESULT_FAIL; | |
135 | + result = UNITTEST_RESULT_FAIL; | |
133 | 136 | break; |
134 | 137 | } |
135 | 138 | if (expected[i].title_len != len) { |
136 | - result = TEST_RESULT_FAIL; | |
139 | + result = UNITTEST_RESULT_FAIL; | |
137 | 140 | break; |
138 | 141 | } |
139 | 142 | if (tc_strncmp(title, expected[i].title, len) != 0) { |
140 | - result = TEST_RESULT_FAIL; | |
143 | + result = UNITTEST_RESULT_FAIL; | |
141 | 144 | break; |
142 | 145 | } |
143 | 146 | } |
144 | 147 | sbjtlist_endread(list, list_iter); |
145 | 148 | |
146 | - if ((result = TEST_RESULT_PASS) && (i != expected_len)) { | |
147 | - result = TEST_RESULT_FAIL; | |
149 | + if ((result = UNITTEST_RESULT_PASS) && (i != expected_len)) { | |
150 | + result = UNITTEST_RESULT_FAIL; | |
148 | 151 | } |
149 | 152 | |
150 | 153 | sbjtlist_delete(list); |
@@ -155,7 +158,7 @@ | ||
155 | 158 | return result; |
156 | 159 | } |
157 | 160 | |
158 | -LOCAL TEST_RESULT test_sbjtlist_1() | |
161 | +LOCAL UNITTEST_RESULT test_sbjtlist_1() | |
159 | 162 | { |
160 | 163 | testsbjtlist_expected_t expected[] = { |
161 | 164 | { |
@@ -182,7 +185,7 @@ | ||
182 | 185 | return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_NUMBER, False, NULL, 0, expected, sizeof(expected)); |
183 | 186 | } |
184 | 187 | |
185 | -LOCAL TEST_RESULT test_sbjtlist_2() | |
188 | +LOCAL UNITTEST_RESULT test_sbjtlist_2() | |
186 | 189 | { |
187 | 190 | testsbjtlist_expected_t expected[] = { |
188 | 191 | { |
@@ -209,7 +212,7 @@ | ||
209 | 212 | return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_RES, False, NULL, 0, expected, sizeof(expected)); |
210 | 213 | } |
211 | 214 | |
212 | -LOCAL TEST_RESULT test_sbjtlist_3() | |
215 | +LOCAL UNITTEST_RESULT test_sbjtlist_3() | |
213 | 216 | { |
214 | 217 | testsbjtlist_expected_t expected[] = { |
215 | 218 | { |
@@ -236,7 +239,7 @@ | ||
236 | 239 | return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_SINCE, False, NULL, 0, expected, sizeof(expected)); |
237 | 240 | } |
238 | 241 | |
239 | -LOCAL TEST_RESULT test_sbjtlist_4() | |
242 | +LOCAL UNITTEST_RESULT test_sbjtlist_4() | |
240 | 243 | { |
241 | 244 | testsbjtlist_expected_t expected[] = { |
242 | 245 | { |
@@ -263,7 +266,7 @@ | ||
263 | 266 | return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_VIGOR, False, NULL, 0, expected, sizeof(expected)); |
264 | 267 | } |
265 | 268 | |
266 | -LOCAL TEST_RESULT test_sbjtlist_5() | |
269 | +LOCAL UNITTEST_RESULT test_sbjtlist_5() | |
267 | 270 | { |
268 | 271 | testsbjtlist_expected_t expected[] = { |
269 | 272 | { |
@@ -290,7 +293,7 @@ | ||
290 | 293 | return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_NUMBER, True, NULL, 0, expected, sizeof(expected)); |
291 | 294 | } |
292 | 295 | |
293 | -LOCAL TEST_RESULT test_sbjtlist_6() | |
296 | +LOCAL UNITTEST_RESULT test_sbjtlist_6() | |
294 | 297 | { |
295 | 298 | testsbjtlist_expected_t expected[] = { |
296 | 299 | { |
@@ -317,7 +320,7 @@ | ||
317 | 320 | return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_RES, True, NULL, 0, expected, sizeof(expected)); |
318 | 321 | } |
319 | 322 | |
320 | -LOCAL TEST_RESULT test_sbjtlist_7() | |
323 | +LOCAL UNITTEST_RESULT test_sbjtlist_7() | |
321 | 324 | { |
322 | 325 | testsbjtlist_expected_t expected[] = { |
323 | 326 | { |
@@ -344,7 +347,7 @@ | ||
344 | 347 | return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_SINCE, True, NULL, 0, expected, sizeof(expected)); |
345 | 348 | } |
346 | 349 | |
347 | -LOCAL TEST_RESULT test_sbjtlist_8() | |
350 | +LOCAL UNITTEST_RESULT test_sbjtlist_8() | |
348 | 351 | { |
349 | 352 | testsbjtlist_expected_t expected[] = { |
350 | 353 | { |
@@ -371,7 +374,7 @@ | ||
371 | 374 | return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_VIGOR, True, NULL, 0, expected, sizeof(expected)); |
372 | 375 | } |
373 | 376 | |
374 | -LOCAL TEST_RESULT test_sbjtlist_9() | |
377 | +LOCAL UNITTEST_RESULT test_sbjtlist_9() | |
375 | 378 | { |
376 | 379 | testsbjtlist_expected_t expected[] = { |
377 | 380 | { |
@@ -384,7 +387,7 @@ | ||
384 | 387 | return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_NUMBER, False, filter, tc_strlen(filter), expected, sizeof(expected)); |
385 | 388 | } |
386 | 389 | |
387 | -LOCAL TEST_RESULT test_sbjtlist_10() | |
390 | +LOCAL UNITTEST_RESULT test_sbjtlist_10() | |
388 | 391 | { |
389 | 392 | testsbjtlist_expected_t expected[] = { |
390 | 393 | { |
@@ -397,7 +400,7 @@ | ||
397 | 400 | return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_NUMBER, False, filter, tc_strlen(filter), expected, sizeof(expected)); |
398 | 401 | } |
399 | 402 | |
400 | -LOCAL TEST_RESULT test_sbjtlist_11() | |
403 | +LOCAL UNITTEST_RESULT test_sbjtlist_11() | |
401 | 404 | { |
402 | 405 | testsbjtlist_expected_t expected[] = { |
403 | 406 | { |
@@ -415,7 +418,7 @@ | ||
415 | 418 | return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_NUMBER, False, filter, tc_strlen(filter), expected, sizeof(expected)); |
416 | 419 | } |
417 | 420 | |
418 | -LOCAL TEST_RESULT test_sbjtlist_12() | |
421 | +LOCAL UNITTEST_RESULT test_sbjtlist_12() | |
419 | 422 | { |
420 | 423 | testsbjtlist_expected_t expected[] = { |
421 | 424 | { |
@@ -428,7 +431,7 @@ | ||
428 | 431 | return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_NUMBER, False, filter, tc_strlen(filter), expected, sizeof(expected)); |
429 | 432 | } |
430 | 433 | |
431 | -LOCAL TEST_RESULT test_sbjtlist_13() | |
434 | +LOCAL UNITTEST_RESULT test_sbjtlist_13() | |
432 | 435 | { |
433 | 436 | testsbjtlist_expected_t expected[] = { |
434 | 437 | }; |
@@ -436,7 +439,7 @@ | ||
436 | 439 | return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_NUMBER, False, filter, tc_strlen(filter), expected, sizeof(expected)); |
437 | 440 | } |
438 | 441 | |
439 | -LOCAL TEST_RESULT test_sbjtlist_14() | |
442 | +LOCAL UNITTEST_RESULT test_sbjtlist_14() | |
440 | 443 | { |
441 | 444 | testsbjtlist_expected_t expected[] = { |
442 | 445 | }; |
@@ -444,35 +447,20 @@ | ||
444 | 447 | return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_NUMBER, False, filter, tc_strlen(filter), expected, sizeof(expected)); |
445 | 448 | } |
446 | 449 | |
447 | -LOCAL VOID test_sbjtlist_printresult(TEST_RESULT (*proc)(), B *test_name) | |
450 | +EXPORT VOID test_sbjtlist_main(unittest_driver_t *driver) | |
448 | 451 | { |
449 | - TEST_RESULT result; | |
450 | - | |
451 | - printf("test_sbjtlist: %s\n", test_name); | |
452 | - printf("---------------------------------------------\n"); | |
453 | - result = proc(); | |
454 | - if (result == TEST_RESULT_PASS) { | |
455 | - printf("--pass---------------------------------------\n"); | |
456 | - } else { | |
457 | - printf("--fail---------------------------------------\n"); | |
458 | - } | |
459 | - printf("---------------------------------------------\n"); | |
452 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtlist_1); | |
453 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtlist_2); | |
454 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtlist_3); | |
455 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtlist_4); | |
456 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtlist_5); | |
457 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtlist_6); | |
458 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtlist_7); | |
459 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtlist_8); | |
460 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtlist_9); | |
461 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtlist_10); | |
462 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtlist_11); | |
463 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtlist_12); | |
464 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtlist_13); | |
465 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtlist_14); | |
460 | 466 | } |
461 | - | |
462 | -EXPORT VOID test_sbjtlist_main() | |
463 | -{ | |
464 | - test_sbjtlist_printresult(test_sbjtlist_1, "test_sbjtlist_1"); | |
465 | - test_sbjtlist_printresult(test_sbjtlist_2, "test_sbjtlist_2"); | |
466 | - test_sbjtlist_printresult(test_sbjtlist_3, "test_sbjtlist_3"); | |
467 | - test_sbjtlist_printresult(test_sbjtlist_4, "test_sbjtlist_4"); | |
468 | - test_sbjtlist_printresult(test_sbjtlist_5, "test_sbjtlist_5"); | |
469 | - test_sbjtlist_printresult(test_sbjtlist_6, "test_sbjtlist_6"); | |
470 | - test_sbjtlist_printresult(test_sbjtlist_7, "test_sbjtlist_7"); | |
471 | - test_sbjtlist_printresult(test_sbjtlist_8, "test_sbjtlist_8"); | |
472 | - test_sbjtlist_printresult(test_sbjtlist_9, "test_sbjtlist_9"); | |
473 | - test_sbjtlist_printresult(test_sbjtlist_10, "test_sbjtlist_10"); | |
474 | - test_sbjtlist_printresult(test_sbjtlist_11, "test_sbjtlist_11"); | |
475 | - test_sbjtlist_printresult(test_sbjtlist_12, "test_sbjtlist_12"); | |
476 | - test_sbjtlist_printresult(test_sbjtlist_13, "test_sbjtlist_13"); | |
477 | - test_sbjtlist_printresult(test_sbjtlist_14, "test_sbjtlist_14"); | |
478 | -} |
@@ -1,7 +1,7 @@ | ||
1 | 1 | /* |
2 | 2 | * test_subjectlayout.c |
3 | 3 | * |
4 | - * Copyright (c) 2009-2011 project bchan | |
4 | + * Copyright (c) 2009-2012 project bchan | |
5 | 5 | * |
6 | 6 | * This software is provided 'as-is', without any express or implied |
7 | 7 | * warranty. In no event will the authors be held liable for any damages |
@@ -24,6 +24,10 @@ | ||
24 | 24 | * |
25 | 25 | */ |
26 | 26 | |
27 | +#include "test.h" | |
28 | + | |
29 | +#include "subjectlayout.h" | |
30 | + | |
27 | 31 | #include <btron/btron.h> |
28 | 32 | #include <btron/dp.h> |
29 | 33 | #include <tcode.h> |
@@ -31,9 +35,8 @@ | ||
31 | 35 | #include <bstring.h> |
32 | 36 | #include <bstdlib.h> |
33 | 37 | |
34 | -#include "test.h" | |
38 | +#include <unittest_driver.h> | |
35 | 39 | |
36 | -#include "subjectlayout.h" | |
37 | 40 | #include "subjectlist.h" |
38 | 41 | #include "subjectparser.h" |
39 | 42 | #include "subjectcache.h" |
@@ -95,7 +98,7 @@ | ||
95 | 98 | free(bmp); |
96 | 99 | } |
97 | 100 | |
98 | -LOCAL TEST_RESULT test_sbjtlayout_1() | |
101 | +LOCAL UNITTEST_RESULT test_sbjtlayout_1() | |
99 | 102 | { |
100 | 103 | BMP *bmp; |
101 | 104 | GID gid; |
@@ -108,15 +111,15 @@ | ||
108 | 111 | sbjtcache_t *cache; |
109 | 112 | sbjtparser_t *parser; |
110 | 113 | sbjtparser_thread_t *thread = NULL; |
111 | - TEST_RESULT result = TEST_RESULT_PASS; | |
114 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
112 | 115 | |
113 | 116 | bmp = test_sbjtlayout_util_alloc_BMP(); |
114 | 117 | if (bmp == NULL) { |
115 | - return TEST_RESULT_FAIL; | |
118 | + return UNITTEST_RESULT_FAIL; | |
116 | 119 | } |
117 | 120 | gid = gopn_mem(NULL, bmp, NULL); |
118 | 121 | if (gid < 0) { |
119 | - return TEST_RESULT_FAIL; | |
122 | + return UNITTEST_RESULT_FAIL; | |
120 | 123 | } |
121 | 124 | |
122 | 125 | cache = sbjtcache_new(); |
@@ -162,22 +165,7 @@ | ||
162 | 165 | return result; |
163 | 166 | } |
164 | 167 | |
165 | -LOCAL VOID test_sbjtlayout_printresult(TEST_RESULT (*proc)(), B *test_name) | |
168 | +EXPORT VOID test_sbjtlayout_main(unittest_driver_t *driver) | |
166 | 169 | { |
167 | - TEST_RESULT result; | |
168 | - | |
169 | - printf("test_sbjtlayout: %s\n", test_name); | |
170 | - printf("---------------------------------------------\n"); | |
171 | - result = proc(); | |
172 | - if (result == TEST_RESULT_PASS) { | |
173 | - printf("--pass---------------------------------------\n"); | |
174 | - } else { | |
175 | - printf("--fail---------------------------------------\n"); | |
176 | - } | |
177 | - printf("---------------------------------------------\n"); | |
170 | + UNITTEST_DRIVER_REGIST(driver, test_sbjtlayout_1); | |
178 | 171 | } |
179 | - | |
180 | -EXPORT VOID test_sbjtlayout_main() | |
181 | -{ | |
182 | - test_sbjtlayout_printresult(test_sbjtlayout_1, "test_sbjtlayout_1"); | |
183 | -} |