• R/O
  • SSH
  • HTTPS

bchan: 提交


Commit MetaInfo

修訂420 (tree)
時間2012-04-11 21:29:07
作者ornse01

Log Message

replace unittest framework to bchanf library.

Change Summary

差異

--- bchanl/trunk/src/test_subjectparser.c (revision 419)
+++ bchanl/trunk/src/test_subjectparser.c (revision 420)
@@ -1,7 +1,7 @@
11 /*
22 * test_subjectparser.c
33 *
4- * Copyright (c) 2009 project bchan
4+ * Copyright (c) 2009-2012 project bchan
55 *
66 * This software is provided 'as-is', without any express or implied
77 * warranty. In no event will the authors be held liable for any damages
@@ -24,14 +24,17 @@
2424 *
2525 */
2626
27+#include "test.h"
28+
29+#include "subjectparser.h"
30+
2731 #include <btron/btron.h>
2832 #include <tcode.h>
2933 #include <bstdio.h>
3034 #include <bstring.h>
3135
32-#include "test.h"
36+#include <unittest_driver.h>
3337
34-#include "subjectparser.h"
3538 #include "subjectcache.h"
3639
3740 LOCAL UB test_subjectparser_testdata_01[] = {
@@ -67,13 +70,13 @@
6770 0x28, 0x35, 0x32, 0x33, 0x29
6871 };
6972
70-LOCAL TEST_RESULT test_sbjtparser_1()
73+LOCAL UNITTEST_RESULT test_sbjtparser_1()
7174 {
7275 W err;
7376 sbjtcache_t *cache;
7477 sbjtparser_t *parser;
7578 sbjtparser_thread_t *thread = NULL;
76- TEST_RESULT result = TEST_RESULT_PASS;
79+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
7780
7881 cache = sbjtcache_new();
7982 sbjtcache_appenddata(cache, test_subjectparser_testdata_01, strlen(test_subjectparser_testdata_01));
@@ -105,22 +108,7 @@
105108 return result;
106109 }
107110
108-LOCAL VOID test_sbjtparser_printresult(TEST_RESULT (*proc)(), B *test_name)
111+EXPORT VOID test_sbjtparser_main(unittest_driver_t *driver)
109112 {
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);
121114 }
122-
123-EXPORT VOID test_sbjtparser_main()
124-{
125- test_sbjtparser_printresult(test_sbjtparser_1, "test_sbjtparser_1");
126-}
--- bchanl/trunk/src/test_subjectcache.c (revision 419)
+++ bchanl/trunk/src/test_subjectcache.c (revision 420)
@@ -1,7 +1,7 @@
11 /*
22 * test_subjectcache.c
33 *
4- * Copyright (c) 2009 project bchan
4+ * Copyright (c) 2009-2012 project bchan
55 *
66 * This software is provided 'as-is', without any express or implied
77 * warranty. In no event will the authors be held liable for any damages
@@ -24,6 +24,10 @@
2424 *
2525 */
2626
27+#include "test.h"
28+
29+#include "subjectcache.h"
30+
2731 #include <btron/btron.h>
2832 #include <tcode.h>
2933 #include <bstdio.h>
@@ -31,10 +35,8 @@
3135 #include <bstdlib.h>
3236 #include <errcode.h>
3337
34-#include "test.h"
38+#include <unittest_driver.h>
3539
36-#include "subjectcache.h"
37-
3840 LOCAL UB test_sbjtcache_testdata_01[] = {"aaaaabbbbbcccccddddd"};
3941 LOCAL UB test_sbjtcache_testdata_01_1[] = {"aaaaa"};
4042 LOCAL UB test_sbjtcache_testdata_01_2[] = {"bbbbb"};
@@ -75,10 +77,10 @@
7577
7678 /* test_sbjtcache_1 */
7779
78-LOCAL TEST_RESULT test_sbjtcache_1()
80+LOCAL UNITTEST_RESULT test_sbjtcache_1()
7981 {
8082 sbjtcache_t *cache;
81- TEST_RESULT result = TEST_RESULT_PASS;
83+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
8284 UB *host;
8385 W host_len;
8486
@@ -86,7 +88,7 @@
8688
8789 sbjtcache_gethost(cache, &host, &host_len);
8890 if ((host != NULL)||(host_len != 0)) {
89- result = TEST_RESULT_FAIL;
91+ result = UNITTEST_RESULT_FAIL;
9092 }
9193
9294 sbjtcache_delete(cache);
@@ -96,10 +98,10 @@
9698
9799 /* test_sbjtcache_2 */
98100
99-LOCAL TEST_RESULT test_sbjtcache_2()
101+LOCAL UNITTEST_RESULT test_sbjtcache_2()
100102 {
101103 sbjtcache_t *cache;
102- TEST_RESULT result = TEST_RESULT_PASS;
104+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
103105 UB *host;
104106 W err, host_len, cmp;
105107
@@ -107,7 +109,7 @@
107109
108110 err = sbjtcache_updatehost(cache, test_sbjtcache_testdata_04, strlen(test_sbjtcache_testdata_04));
109111 if (err < 0) {
110- result = TEST_RESULT_FAIL;
112+ result = UNITTEST_RESULT_FAIL;
111113 }
112114
113115 sbjtcache_gethost(cache, &host, &host_len);
@@ -114,7 +116,7 @@
114116 cmp = memcmp(host, test_sbjtcache_testdata_04, host_len);
115117 if (cmp != 0) {
116118 printf("sbjtcache_gethost: data error\n");
117- result = TEST_RESULT_FAIL;
119+ result = UNITTEST_RESULT_FAIL;
118120 }
119121
120122 sbjtcache_delete(cache);
@@ -124,10 +126,10 @@
124126
125127 /* test_sbjtcache_3 */
126128
127-LOCAL TEST_RESULT test_sbjtcache_3()
129+LOCAL UNITTEST_RESULT test_sbjtcache_3()
128130 {
129131 sbjtcache_t *cache;
130- TEST_RESULT result = TEST_RESULT_PASS;
132+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
131133 UB *board;
132134 W board_len;
133135
@@ -135,7 +137,7 @@
135137
136138 sbjtcache_getboard(cache, &board, &board_len);
137139 if ((board != NULL)||(board_len != 0)) {
138- result = TEST_RESULT_FAIL;
140+ result = UNITTEST_RESULT_FAIL;
139141 }
140142
141143 sbjtcache_delete(cache);
@@ -145,10 +147,10 @@
145147
146148 /* test_sbjtcache_4 */
147149
148-LOCAL TEST_RESULT test_sbjtcache_4()
150+LOCAL UNITTEST_RESULT test_sbjtcache_4()
149151 {
150152 sbjtcache_t *cache;
151- TEST_RESULT result = TEST_RESULT_PASS;
153+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
152154 UB *board;
153155 W err, board_len, cmp;
154156
@@ -156,7 +158,7 @@
156158
157159 err = sbjtcache_updateboard(cache, test_sbjtcache_testdata_05, strlen(test_sbjtcache_testdata_05));
158160 if (err < 0) {
159- result = TEST_RESULT_FAIL;
161+ result = UNITTEST_RESULT_FAIL;
160162 }
161163
162164 sbjtcache_getboard(cache, &board, &board_len);
@@ -163,7 +165,7 @@
163165 cmp = memcmp(board, test_sbjtcache_testdata_05, board_len);
164166 if (cmp != 0) {
165167 printf("sbjtcache_getboard: data error\n");
166- result = TEST_RESULT_FAIL;
168+ result = UNITTEST_RESULT_FAIL;
167169 }
168170
169171 sbjtcache_delete(cache);
@@ -173,10 +175,10 @@
173175
174176 /* test_sbjtcache_5 */
175177
176-LOCAL TEST_RESULT test_sbjtcache_5_testseq()
178+LOCAL UNITTEST_RESULT test_sbjtcache_5_testseq()
177179 {
178180 sbjtcache_t *cache;
179- TEST_RESULT result = TEST_RESULT_PASS;
181+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
180182 UB *header;
181183 W err, header_len, cmp;
182184
@@ -186,18 +188,18 @@
186188 if (err < 0) {
187189 printf("sbjtcache_updatelataestheade error\n");
188190 sbjtcache_delete(cache);
189- return TEST_RESULT_FAIL;
191+ return UNITTEST_RESULT_FAIL;
190192 }
191193
192194 sbjtcache_getlatestheader(cache, &header, &header_len);
193195 if (header_len != strlen(test_sbjtcache_testdata_07)) {
194196 printf("sbjtcache_getlatestheader: length error\n");
195- result = TEST_RESULT_FAIL;
197+ result = UNITTEST_RESULT_FAIL;
196198 }
197199 cmp = memcmp(header, test_sbjtcache_testdata_07, header_len);
198200 if (cmp != 0) {
199201 printf("sbjtcache_getlatestheader: data error\n");
200- result = TEST_RESULT_FAIL;
202+ result = UNITTEST_RESULT_FAIL;
201203 }
202204
203205 sbjtcache_delete(cache);
@@ -205,7 +207,7 @@
205207 return result;
206208 }
207209
208-LOCAL TEST_RESULT test_sbjtcache_5()
210+LOCAL UNITTEST_RESULT test_sbjtcache_5()
209211 {
210212 return test_sbjtcache_5_testseq();
211213 }
@@ -212,10 +214,10 @@
212214
213215 /* test_sbjtcache_6 */
214216
215-LOCAL TEST_RESULT test_sbjtcache_6_testseq()
217+LOCAL UNITTEST_RESULT test_sbjtcache_6_testseq()
216218 {
217219 sbjtcache_t *cache;
218- TEST_RESULT result = TEST_RESULT_PASS;
220+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
219221 UB *header;
220222 W err, header_len, cmp;
221223
@@ -225,24 +227,24 @@
225227 if (err < 0) {
226228 printf("sbjtcache_updatelataestheade error\n");
227229 sbjtcache_delete(cache);
228- return TEST_RESULT_FAIL;
230+ return UNITTEST_RESULT_FAIL;
229231 }
230232 err = sbjtcache_updatelatestheader(cache, test_sbjtcache_testdata_02, strlen(test_sbjtcache_testdata_02));
231233 if (err < 0) {
232234 printf("sbjtcache_updatelataestheade error\n");
233235 sbjtcache_delete(cache);
234- return TEST_RESULT_FAIL;
236+ return UNITTEST_RESULT_FAIL;
235237 }
236238
237239 sbjtcache_getlatestheader(cache, &header, &header_len);
238240 if (header_len != strlen(test_sbjtcache_testdata_02)) {
239241 printf("sbjtcache_getlatestheader: length error\n");
240- result = TEST_RESULT_FAIL;
242+ result = UNITTEST_RESULT_FAIL;
241243 }
242244 cmp = memcmp(header, test_sbjtcache_testdata_02, header_len);
243245 if (cmp != 0) {
244246 printf("sbjtcache_getlatestheader: data error\n");
245- result = TEST_RESULT_FAIL;
247+ result = UNITTEST_RESULT_FAIL;
246248 }
247249
248250 sbjtcache_delete(cache);
@@ -250,7 +252,7 @@
250252 return result;
251253 }
252254
253-LOCAL TEST_RESULT test_sbjtcache_6()
255+LOCAL UNITTEST_RESULT test_sbjtcache_6()
254256 {
255257 return test_sbjtcache_6_testseq();
256258 }
@@ -257,10 +259,10 @@
257259
258260 /* test_sbjtcache_7 */
259261
260-LOCAL TEST_RESULT test_sbjtcache_7_testseq()
262+LOCAL UNITTEST_RESULT test_sbjtcache_7_testseq()
261263 {
262264 sbjtcache_t *cache;
263- TEST_RESULT result = TEST_RESULT_PASS;
265+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
264266 UB *header;
265267 W header_len;
266268
@@ -269,11 +271,11 @@
269271 sbjtcache_getlatestheader(cache, &header, &header_len);
270272 if (header != NULL) {
271273 printf("sbjtcache_getlatestheader: data error\n");
272- result = TEST_RESULT_FAIL;
274+ result = UNITTEST_RESULT_FAIL;
273275 }
274276 if (header_len != 0) {
275277 printf("sbjtcache_getlatestheader: length error\n");
276- result = TEST_RESULT_FAIL;
278+ result = UNITTEST_RESULT_FAIL;
277279 }
278280
279281 sbjtcache_delete(cache);
@@ -281,7 +283,7 @@
281283 return result;
282284 }
283285
284-LOCAL TEST_RESULT test_sbjtcache_7()
286+LOCAL UNITTEST_RESULT test_sbjtcache_7()
285287 {
286288 return test_sbjtcache_7_testseq();
287289 }
@@ -288,12 +290,12 @@
288290
289291 /* test_sbjtcache_8 */
290292
291-LOCAL TEST_RESULT test_sbjtcache_8_testseq()
293+LOCAL UNITTEST_RESULT test_sbjtcache_8_testseq()
292294 {
293295 W err;
294296 sbjtcache_t *cache;
295297 sbjtcache_datareadcontext_t *context;
296- TEST_RESULT result = TEST_RESULT_PASS;
298+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
297299 Bool ok;
298300
299301 cache = sbjtcache_new();
@@ -302,25 +304,25 @@
302304 if (err < 0) {
303305 printf("sbjtcache_appenddata error 1\n");
304306 sbjtcache_delete(cache);
305- return TEST_RESULT_FAIL;
307+ return UNITTEST_RESULT_FAIL;
306308 }
307309 err = sbjtcache_appenddata(cache, test_sbjtcache_testdata_01_2, strlen(test_sbjtcache_testdata_01_2));
308310 if (err < 0) {
309311 printf("sbjtcache_appenddata error 2\n");
310312 sbjtcache_delete(cache);
311- return TEST_RESULT_FAIL;
313+ return UNITTEST_RESULT_FAIL;
312314 }
313315 err = sbjtcache_appenddata(cache, test_sbjtcache_testdata_01_3, strlen(test_sbjtcache_testdata_01_3));
314316 if (err < 0) {
315317 printf("sbjtcache_appenddata error 3\n");
316318 sbjtcache_delete(cache);
317- return TEST_RESULT_FAIL;
319+ return UNITTEST_RESULT_FAIL;
318320 }
319321 err = sbjtcache_appenddata(cache, test_sbjtcache_testdata_01_4, strlen(test_sbjtcache_testdata_01_4));
320322 if (err < 0) {
321323 printf("sbjtcache_appenddata error 4\n");
322324 sbjtcache_delete(cache);
323- return TEST_RESULT_FAIL;
325+ return UNITTEST_RESULT_FAIL;
324326 }
325327
326328 context = sbjtcache_startdataread(cache, 0);
@@ -327,11 +329,11 @@
327329 if (context == NULL) {
328330 printf("sbjtcache_startdataread error\n");
329331 sbjtcache_delete(cache);
330- return TEST_RESULT_FAIL;
332+ return UNITTEST_RESULT_FAIL;
331333 }
332334 ok = test_sbjtcache_util_cmp_ctx_str(context, test_sbjtcache_testdata_01, strlen(test_sbjtcache_testdata_01));
333335 if (ok != True) {
334- result = TEST_RESULT_FAIL;
336+ result = UNITTEST_RESULT_FAIL;
335337 }
336338 sbjtcache_enddataread(cache, context);
337339
@@ -340,7 +342,7 @@
340342 return result;
341343 }
342344
343-LOCAL TEST_RESULT test_sbjtcache_8()
345+LOCAL UNITTEST_RESULT test_sbjtcache_8()
344346 {
345347 return test_sbjtcache_8_testseq();
346348 }
@@ -347,12 +349,12 @@
347349
348350 /* test_sbjtcache_9 */
349351
350-LOCAL TEST_RESULT test_sbjtcache_9_testseq()
352+LOCAL UNITTEST_RESULT test_sbjtcache_9_testseq()
351353 {
352354 W err;
353355 sbjtcache_t *cache;
354356 sbjtcache_datareadcontext_t *context;
355- TEST_RESULT result = TEST_RESULT_PASS;
357+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
356358 UB *bin_cache;
357359 W len_cache;
358360 Bool ok;
@@ -363,35 +365,35 @@
363365 if (err < 0) {
364366 printf("sbjtcache_appenddata error 1\n");
365367 sbjtcache_delete(cache);
366- return TEST_RESULT_FAIL;
368+ return UNITTEST_RESULT_FAIL;
367369 }
368370 err = sbjtcache_appenddata(cache, test_sbjtcache_testdata_01_2, strlen(test_sbjtcache_testdata_01_2));
369371 if (err < 0) {
370372 printf("sbjtcache_appenddata error 2\n");
371373 sbjtcache_delete(cache);
372- return TEST_RESULT_FAIL;
374+ return UNITTEST_RESULT_FAIL;
373375 }
374376 err = sbjtcache_appenddata(cache, test_sbjtcache_testdata_01_3, strlen(test_sbjtcache_testdata_01_3));
375377 if (err < 0) {
376378 printf("sbjtcache_appenddata error 3\n");
377379 sbjtcache_delete(cache);
378- return TEST_RESULT_FAIL;
380+ return UNITTEST_RESULT_FAIL;
379381 }
380382 err = sbjtcache_appenddata(cache, test_sbjtcache_testdata_01_4, strlen(test_sbjtcache_testdata_01_4));
381383 if (err < 0) {
382384 printf("sbjtcache_appenddata error 4\n");
383385 sbjtcache_delete(cache);
384- return TEST_RESULT_FAIL;
386+ return UNITTEST_RESULT_FAIL;
385387 }
386388
387389 context = sbjtcache_startdataread(cache, strlen(test_sbjtcache_testdata_01)+5);
388390 if (context == NULL) {
389391 sbjtcache_delete(cache);
390- return TEST_RESULT_FAIL;
392+ return UNITTEST_RESULT_FAIL;
391393 }
392394 ok = sbjtcache_datareadcontext_nextdata(context, &bin_cache, &len_cache);
393395 if (ok == True) {
394- result = TEST_RESULT_FAIL;
396+ result = UNITTEST_RESULT_FAIL;
395397 }
396398 sbjtcache_enddataread(cache, context);
397399
@@ -400,35 +402,20 @@
400402 return result;
401403 }
402404
403-LOCAL TEST_RESULT test_sbjtcache_9()
405+LOCAL UNITTEST_RESULT test_sbjtcache_9()
404406 {
405407 return test_sbjtcache_9_testseq();
406408 }
407409
408-LOCAL VOID test_sbjtcache_printresult(TEST_RESULT (*proc)(), B *test_name)
410+EXPORT VOID test_sbjtcache_main(unittest_driver_t *driver)
409411 {
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);
421421 }
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-}
--- bchanl/trunk/src/test_bbsmenulayout.c (revision 419)
+++ bchanl/trunk/src/test_bbsmenulayout.c (revision 420)
@@ -1,7 +1,7 @@
11 /*
22 * test_bbsmenulayout.c
33 *
4- * Copyright (c) 2009 project bchan
4+ * Copyright (c) 2009-2012 project bchan
55 *
66 * This software is provided 'as-is', without any express or implied
77 * warranty. In no event will the authors be held liable for any damages
@@ -24,6 +24,10 @@
2424 *
2525 */
2626
27+#include "test.h"
28+
29+#include "bbsmenulayout.h"
30+
2731 #include <btron/btron.h>
2832 #include <btron/dp.h>
2933 #include <tcode.h>
@@ -31,9 +35,8 @@
3135 #include <bstring.h>
3236 #include <bstdlib.h>
3337
34-#include "test.h"
38+#include <unittest_driver.h>
3539
36-#include "bbsmenulayout.h"
3740 #include "bbsmenuparser.h"
3841 #include "bbsmenucache.h"
3942
@@ -99,7 +102,7 @@
99102 free(bmp);
100103 }
101104
102-LOCAL TEST_RESULT test_bbsmnlayout_1()
105+LOCAL UNITTEST_RESULT test_bbsmnlayout_1()
103106 {
104107 BMP *bmp;
105108 GID gid;
@@ -108,15 +111,15 @@
108111 bbsmncache_t *cache;
109112 bbsmnparser_t *parser;
110113 bbsmnparser_item_t *item = NULL;
111- TEST_RESULT result = TEST_RESULT_PASS;
114+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
112115
113116 bmp = test_bbsmnlayout_util_alloc_BMP();
114117 if (bmp == NULL) {
115- return TEST_RESULT_FAIL;
118+ return UNITTEST_RESULT_FAIL;
116119 }
117120 gid = gopn_mem(NULL, bmp, NULL);
118121 if (gid < 0) {
119- return TEST_RESULT_FAIL;
122+ return UNITTEST_RESULT_FAIL;
120123 }
121124
122125 cache = bbsmncache_new();
@@ -148,22 +151,7 @@
148151 return result;
149152 }
150153
151-LOCAL VOID test_bbsmnlayout_printresult(TEST_RESULT (*proc)(), B *test_name)
154+EXPORT VOID test_bbsmnlayout_main(unittest_driver_t *driver)
152155 {
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);
164157 }
165-
166-EXPORT VOID test_bbsmnlayout_main()
167-{
168- test_bbsmnlayout_printresult(test_bbsmnlayout_1, "test_bbsmnlayout_1");
169-}
--- bchanl/trunk/src/test_bbsmenufilter.c (revision 419)
+++ bchanl/trunk/src/test_bbsmenufilter.c (revision 420)
@@ -1,7 +1,7 @@
11 /*
22 * test_bbsmenufilter.c
33 *
4- * Copyright (c) 2010 project bchan
4+ * Copyright (c) 2010-2012 project bchan
55 *
66 * This software is provided 'as-is', without any express or implied
77 * warranty. In no event will the authors be held liable for any damages
@@ -24,11 +24,14 @@
2424 *
2525 */
2626
27+#include "test.h"
28+
29+#include "bbsmenufilter.h"
30+
2731 #include <bstdio.h>
2832
29-#include "test.h"
33+#include <unittest_driver.h>
3034
31-#include "bbsmenufilter.h"
3235 #include "bbsmenuparser.h"
3336 #include "bbsmenucache.h"
3437
@@ -69,7 +72,7 @@
6972 </BODY></HTML>
7073 "};
7174
72-LOCAL TEST_RESULT test_bbsmnfilter_1()
75+LOCAL UNITTEST_RESULT test_bbsmnfilter_1()
7376 {
7477 W ret,err;
7578 bbsmncache_t *cache;
@@ -76,7 +79,7 @@
7679 bbsmnparser_t *parser;
7780 bbsmnparser_item_t *item = NULL;
7881 bbsmnfilter_t *filter = NULL;
79- TEST_RESULT result = TEST_RESULT_PASS;
82+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
8083
8184 cache = bbsmncache_new();
8285 bbsmncache_appenddata(cache, test_bbsmnfilter_testdata_01, strlen(test_bbsmnfilter_testdata_01));
@@ -120,13 +123,13 @@
120123 return result;
121124 }
122125
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)
124127 {
125128 switch(i) {
126129 case 0:
127130 case 5:
128131 if (item->category == NULL) {
129- return TEST_RESULT_FAIL;
132+ return UNITTEST_RESULT_FAIL;
130133 }
131134 break;
132135 case 1:
@@ -138,17 +141,17 @@
138141 case 8:
139142 case 9:
140143 if ((item->category != NULL)||(item->url == NULL)||(item->title == NULL)) {
141- return TEST_RESULT_FAIL;
144+ return UNITTEST_RESULT_FAIL;
142145 }
143146 break;
144147 default:
145- return TEST_RESULT_FAIL;
148+ return UNITTEST_RESULT_FAIL;
146149 break;
147150 }
148- return TEST_RESULT_PASS;
151+ return UNITTEST_RESULT_PASS;
149152 }
150153
151-LOCAL TEST_RESULT test_bbsmnfilter_2()
154+LOCAL UNITTEST_RESULT test_bbsmnfilter_2()
152155 {
153156 W i = 0, ret,err;
154157 bbsmncache_t *cache;
@@ -155,7 +158,7 @@
155158 bbsmnparser_t *parser;
156159 bbsmnparser_item_t *item = NULL;
157160 bbsmnfilter_t *filter = NULL;
158- TEST_RESULT result = TEST_RESULT_PASS;
161+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
159162
160163 cache = bbsmncache_new();
161164 bbsmncache_appenddata(cache, test_bbsmnfilter_testdata_01, strlen(test_bbsmnfilter_testdata_01));
@@ -176,7 +179,7 @@
176179 i++;
177180 bbsmnparser_item_delete(item);
178181
179- if (result == TEST_RESULT_FAIL) {
182+ if (result == UNITTEST_RESULT_FAIL) {
180183 printf("fail i = %d\n", i-1);
181184 break;
182185 }
@@ -183,7 +186,7 @@
183186 } else {
184187 if ((ret != BBSMNFILTER_OUTPUTITEM_WAITNEXT)&&(ret != BBSMNFILTER_OUTPUTITEM_END)) {
185188 printf("invalid return value\n");
186- result = TEST_RESULT_FAIL;
189+ result = UNITTEST_RESULT_FAIL;
187190 }
188191 break;
189192 }
@@ -191,7 +194,7 @@
191194 break;
192195 }
193196 }
194- if (result == TEST_RESULT_FAIL) {
197+ if (result == UNITTEST_RESULT_FAIL) {
195198 break;
196199 }
197200 }
@@ -204,7 +207,7 @@
204207 i++;
205208 bbsmnparser_item_delete(item);
206209
207- if (result == TEST_RESULT_FAIL) {
210+ if (result == UNITTEST_RESULT_FAIL) {
208211 printf("fail i = %d\n", i-1);
209212 break;
210213 }
@@ -215,12 +218,12 @@
215218 if (ret == BBSMNFILTER_OUTPUTITEM_END) {
216219 break;
217220 }
218- result = TEST_RESULT_FAIL;
221+ result = UNITTEST_RESULT_FAIL;
219222 printf("invalid return value\n");
220223 break;
221224 }
222225 if (i != 10) {
223- result = TEST_RESULT_FAIL;
226+ result = UNITTEST_RESULT_FAIL;
224227 printf("fail: too meny items\n");
225228 }
226229
@@ -232,23 +235,8 @@
232235 return result;
233236 }
234237
235-LOCAL VOID test_bbsmnfilter_printresult(TEST_RESULT (*proc)(), B *test_name)
238+EXPORT VOID test_bbsmnfilter_main(unittest_driver_t *driver)
236239 {
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);
248242 }
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-}
--- bchanl/trunk/src/test_bbsmenuparser.c (revision 419)
+++ bchanl/trunk/src/test_bbsmenuparser.c (revision 420)
@@ -1,7 +1,7 @@
11 /*
22 * test_bbsmenuparser.c
33 *
4- * Copyright (c) 2009 project bchan
4+ * Copyright (c) 2009-2012 project bchan
55 *
66 * This software is provided 'as-is', without any express or implied
77 * warranty. In no event will the authors be held liable for any damages
@@ -24,14 +24,17 @@
2424 *
2525 */
2626
27+#include "test.h"
28+
29+#include "bbsmenuparser.h"
30+
2731 #include <btron/btron.h>
2832 #include <tcode.h>
2933 #include <bstdio.h>
3034 #include <bstring.h>
3135
32-#include "test.h"
36+#include <unittest_driver.h>
3337
34-#include "bbsmenuparser.h"
3538 #include "bbsmenucache.h"
3639
3740 LOCAL UB test_bbsmnparser_testdata_01[] = {
@@ -71,13 +74,13 @@
7174 </BODY></HTML>
7275 "};
7376
74-LOCAL TEST_RESULT test_bbsmnparser_1()
77+LOCAL UNITTEST_RESULT test_bbsmnparser_1()
7578 {
7679 W err;
7780 bbsmncache_t *cache;
7881 bbsmnparser_t *parser;
7982 bbsmnparser_item_t *item = NULL;
80- TEST_RESULT result = TEST_RESULT_PASS;
83+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
8184
8285 cache = bbsmncache_new();
8386 bbsmncache_appenddata(cache, test_bbsmnparser_testdata_01, strlen(test_bbsmnparser_testdata_01));
@@ -112,7 +115,7 @@
112115 return result;
113116 }
114117
115-LOCAL TEST_RESULT test_bbsmnparser_2()
118+LOCAL UNITTEST_RESULT test_bbsmnparser_2()
116119 {
117120 bbsmnparser_item_t item;
118121 Bool check;
@@ -126,13 +129,13 @@
126129
127130 check = bbsmnparser_item_checkboradurl(&item);
128131 if (check == False) {
129- return TEST_RESULT_PASS;
132+ return UNITTEST_RESULT_PASS;
130133 }
131134
132- return TEST_RESULT_FAIL;
135+ return UNITTEST_RESULT_FAIL;
133136 }
134137
135-LOCAL TEST_RESULT test_bbsmnparser_3()
138+LOCAL UNITTEST_RESULT test_bbsmnparser_3()
136139 {
137140 bbsmnparser_item_t item;
138141 Bool check;
@@ -146,13 +149,13 @@
146149
147150 check = bbsmnparser_item_checkboradurl(&item);
148151 if (check == True) {
149- return TEST_RESULT_PASS;
152+ return UNITTEST_RESULT_PASS;
150153 }
151154
152- return TEST_RESULT_FAIL;
155+ return UNITTEST_RESULT_FAIL;
153156 }
154157
155-LOCAL TEST_RESULT test_bbsmnparser_4()
158+LOCAL UNITTEST_RESULT test_bbsmnparser_4()
156159 {
157160 bbsmnparser_item_t item;
158161 Bool check;
@@ -166,13 +169,13 @@
166169
167170 check = bbsmnparser_item_checkboradurl(&item);
168171 if (check == False) {
169- return TEST_RESULT_PASS;
172+ return UNITTEST_RESULT_PASS;
170173 }
171174
172- return TEST_RESULT_FAIL;
175+ return UNITTEST_RESULT_FAIL;
173176 }
174177
175-LOCAL TEST_RESULT test_bbsmnparser_5()
178+LOCAL UNITTEST_RESULT test_bbsmnparser_5()
176179 {
177180 bbsmnparser_item_t item;
178181 Bool check;
@@ -186,13 +189,13 @@
186189
187190 check = bbsmnparser_item_checkboradurl(&item);
188191 if (check == False) {
189- return TEST_RESULT_PASS;
192+ return UNITTEST_RESULT_PASS;
190193 }
191194
192- return TEST_RESULT_FAIL;
195+ return UNITTEST_RESULT_FAIL;
193196 }
194197
195-LOCAL TEST_RESULT test_bbsmnparser_6()
198+LOCAL UNITTEST_RESULT test_bbsmnparser_6()
196199 {
197200 bbsmnparser_item_t item;
198201 Bool check;
@@ -206,13 +209,13 @@
206209
207210 check = bbsmnparser_item_checkboradurl(&item);
208211 if (check == False) {
209- return TEST_RESULT_PASS;
212+ return UNITTEST_RESULT_PASS;
210213 }
211214
212- return TEST_RESULT_FAIL;
215+ return UNITTEST_RESULT_FAIL;
213216 }
214217
215-LOCAL TEST_RESULT test_bbsmnparser_7()
218+LOCAL UNITTEST_RESULT test_bbsmnparser_7()
216219 {
217220 bbsmnparser_item_t item;
218221 Bool check;
@@ -226,13 +229,13 @@
226229
227230 check = bbsmnparser_item_checkboradurl(&item);
228231 if (check == False) {
229- return TEST_RESULT_PASS;
232+ return UNITTEST_RESULT_PASS;
230233 }
231234
232- return TEST_RESULT_FAIL;
235+ return UNITTEST_RESULT_FAIL;
233236 }
234237
235-LOCAL TEST_RESULT test_bbsmnparser_8()
238+LOCAL UNITTEST_RESULT test_bbsmnparser_8()
236239 {
237240 bbsmnparser_item_t item;
238241 Bool check;
@@ -246,13 +249,13 @@
246249
247250 check = bbsmnparser_item_checkboradurl(&item);
248251 if (check == True) {
249- return TEST_RESULT_PASS;
252+ return UNITTEST_RESULT_PASS;
250253 }
251254
252- return TEST_RESULT_FAIL;
255+ return UNITTEST_RESULT_FAIL;
253256 }
254257
255-LOCAL TEST_RESULT test_bbsmnparser_9()
258+LOCAL UNITTEST_RESULT test_bbsmnparser_9()
256259 {
257260 bbsmnparser_item_t item;
258261 Bool check;
@@ -266,13 +269,13 @@
266269
267270 check = bbsmnparser_item_checkboradurl(&item);
268271 if (check == False) {
269- return TEST_RESULT_PASS;
272+ return UNITTEST_RESULT_PASS;
270273 }
271274
272- return TEST_RESULT_FAIL;
275+ return UNITTEST_RESULT_FAIL;
273276 }
274277
275-LOCAL TEST_RESULT test_bbsmnparser_10()
278+LOCAL UNITTEST_RESULT test_bbsmnparser_10()
276279 {
277280 bbsmnparser_item_t item;
278281 Bool check;
@@ -286,13 +289,13 @@
286289
287290 check = bbsmnparser_item_checkboradurl(&item);
288291 if (check == False) {
289- return TEST_RESULT_PASS;
292+ return UNITTEST_RESULT_PASS;
290293 }
291294
292- return TEST_RESULT_FAIL;
295+ return UNITTEST_RESULT_FAIL;
293296 }
294297
295-LOCAL TEST_RESULT test_bbsmnparser_11()
298+LOCAL UNITTEST_RESULT test_bbsmnparser_11()
296299 {
297300 bbsmnparser_item_t item;
298301 Bool check;
@@ -306,13 +309,13 @@
306309
307310 check = bbsmnparser_item_checkboradurl(&item);
308311 if (check == False) {
309- return TEST_RESULT_PASS;
312+ return UNITTEST_RESULT_PASS;
310313 }
311314
312- return TEST_RESULT_FAIL;
315+ return UNITTEST_RESULT_FAIL;
313316 }
314317
315-LOCAL TEST_RESULT test_bbsmnparser_12()
318+LOCAL UNITTEST_RESULT test_bbsmnparser_12()
316319 {
317320 bbsmnparser_item_t item;
318321 Bool check;
@@ -326,13 +329,13 @@
326329
327330 check = bbsmnparser_item_checkboradurl(&item);
328331 if (check == False) {
329- return TEST_RESULT_PASS;
332+ return UNITTEST_RESULT_PASS;
330333 }
331334
332- return TEST_RESULT_FAIL;
335+ return UNITTEST_RESULT_FAIL;
333336 }
334337
335-LOCAL TEST_RESULT test_bbsmnparser_13()
338+LOCAL UNITTEST_RESULT test_bbsmnparser_13()
336339 {
337340 bbsmnparser_item_t item;
338341 Bool check;
@@ -346,13 +349,13 @@
346349
347350 check = bbsmnparser_item_checkboradurl(&item);
348351 if (check == False) {
349- return TEST_RESULT_PASS;
352+ return UNITTEST_RESULT_PASS;
350353 }
351354
352- return TEST_RESULT_FAIL;
355+ return UNITTEST_RESULT_FAIL;
353356 }
354357
355-LOCAL TEST_RESULT test_bbsmnparser_14()
358+LOCAL UNITTEST_RESULT test_bbsmnparser_14()
356359 {
357360 bbsmnparser_item_t item;
358361 Bool check;
@@ -366,13 +369,13 @@
366369
367370 check = bbsmnparser_item_checkboradurl(&item);
368371 if (check == False) {
369- return TEST_RESULT_PASS;
372+ return UNITTEST_RESULT_PASS;
370373 }
371374
372- return TEST_RESULT_FAIL;
375+ return UNITTEST_RESULT_FAIL;
373376 }
374377
375-LOCAL TEST_RESULT test_bbsmnparser_15()
378+LOCAL UNITTEST_RESULT test_bbsmnparser_15()
376379 {
377380 bbsmnparser_item_t item;
378381 Bool check;
@@ -386,42 +389,27 @@
386389
387390 check = bbsmnparser_item_checkboradurl(&item);
388391 if (check == False) {
389- return TEST_RESULT_PASS;
392+ return UNITTEST_RESULT_PASS;
390393 }
391394
392- return TEST_RESULT_FAIL;
395+ return UNITTEST_RESULT_FAIL;
393396 }
394397
395-LOCAL VOID test_bbsmnparser_printresult(TEST_RESULT (*proc)(), B *test_name)
398+EXPORT VOID test_bbsmnparser_main(unittest_driver_t *driver)
396399 {
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);
408415 }
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-}
--- bchanl/trunk/src/test_bbsmenucache.c (revision 419)
+++ bchanl/trunk/src/test_bbsmenucache.c (revision 420)
@@ -1,7 +1,7 @@
11 /*
22 * test_bbsmenucache.c
33 *
4- * Copyright (c) 2009 project bchan
4+ * Copyright (c) 2009-2012 project bchan
55 *
66 * This software is provided 'as-is', without any express or implied
77 * warranty. In no event will the authors be held liable for any damages
@@ -24,6 +24,10 @@
2424 *
2525 */
2626
27+#include "test.h"
28+
29+#include "bbsmenucache.h"
30+
2731 #include <btron/btron.h>
2832 #include <tcode.h>
2933 #include <bstdio.h>
@@ -31,10 +35,8 @@
3135 #include <bstdlib.h>
3236 #include <errcode.h>
3337
34-#include "test.h"
38+#include <unittest_driver.h>
3539
36-#include "bbsmenucache.h"
37-
3840 LOCAL UB test_bbsmncache_testdata_01[] = {"aaaaabbbbbcccccddddd"};
3941 LOCAL UB test_bbsmncache_testdata_01_1[] = {"aaaaa"};
4042 LOCAL UB test_bbsmncache_testdata_01_2[] = {"bbbbb"};
@@ -73,10 +75,10 @@
7375
7476 /* test_bbsmncache_1 */
7577
76-LOCAL TEST_RESULT test_bbsmncache_1_testseq()
78+LOCAL UNITTEST_RESULT test_bbsmncache_1_testseq()
7779 {
7880 bbsmncache_t *cache;
79- TEST_RESULT result = TEST_RESULT_PASS;
81+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
8082 UB *header;
8183 W err, header_len, cmp;
8284
@@ -86,18 +88,18 @@
8688 if (err < 0) {
8789 printf("bbsmncache_updatelataestheade error\n");
8890 bbsmncache_delete(cache);
89- return TEST_RESULT_FAIL;
91+ return UNITTEST_RESULT_FAIL;
9092 }
9193
9294 bbsmncache_getlatestheader(cache, &header, &header_len);
9395 if (header_len != strlen(test_bbsmncache_testdata_07)) {
9496 printf("bbsmncache_getlatestheader: length error\n");
95- result = TEST_RESULT_FAIL;
97+ result = UNITTEST_RESULT_FAIL;
9698 }
9799 cmp = memcmp(header, test_bbsmncache_testdata_07, header_len);
98100 if (cmp != 0) {
99101 printf("bbsmncache_getlatestheader: data error\n");
100- result = TEST_RESULT_FAIL;
102+ result = UNITTEST_RESULT_FAIL;
101103 }
102104
103105 bbsmncache_delete(cache);
@@ -105,7 +107,7 @@
105107 return result;
106108 }
107109
108-LOCAL TEST_RESULT test_bbsmncache_1()
110+LOCAL UNITTEST_RESULT test_bbsmncache_1()
109111 {
110112 return test_bbsmncache_1_testseq();
111113 }
@@ -112,10 +114,10 @@
112114
113115 /* test_bbsmncache_2 */
114116
115-LOCAL TEST_RESULT test_bbsmncache_2_testseq()
117+LOCAL UNITTEST_RESULT test_bbsmncache_2_testseq()
116118 {
117119 bbsmncache_t *cache;
118- TEST_RESULT result = TEST_RESULT_PASS;
120+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
119121 UB *header;
120122 W err, header_len, cmp;
121123
@@ -125,24 +127,24 @@
125127 if (err < 0) {
126128 printf("bbsmncache_updatelataestheade error\n");
127129 bbsmncache_delete(cache);
128- return TEST_RESULT_FAIL;
130+ return UNITTEST_RESULT_FAIL;
129131 }
130132 err = bbsmncache_updatelatestheader(cache, test_bbsmncache_testdata_02, strlen(test_bbsmncache_testdata_02));
131133 if (err < 0) {
132134 printf("bbsmncache_updatelataestheade error\n");
133135 bbsmncache_delete(cache);
134- return TEST_RESULT_FAIL;
136+ return UNITTEST_RESULT_FAIL;
135137 }
136138
137139 bbsmncache_getlatestheader(cache, &header, &header_len);
138140 if (header_len != strlen(test_bbsmncache_testdata_02)) {
139141 printf("bbsmncache_getlatestheader: length error\n");
140- result = TEST_RESULT_FAIL;
142+ result = UNITTEST_RESULT_FAIL;
141143 }
142144 cmp = memcmp(header, test_bbsmncache_testdata_02, header_len);
143145 if (cmp != 0) {
144146 printf("bbsmncache_getlatestheader: data error\n");
145- result = TEST_RESULT_FAIL;
147+ result = UNITTEST_RESULT_FAIL;
146148 }
147149
148150 bbsmncache_delete(cache);
@@ -150,7 +152,7 @@
150152 return result;
151153 }
152154
153-LOCAL TEST_RESULT test_bbsmncache_2()
155+LOCAL UNITTEST_RESULT test_bbsmncache_2()
154156 {
155157 return test_bbsmncache_2_testseq();
156158 }
@@ -157,10 +159,10 @@
157159
158160 /* test_bbsmncache_3 */
159161
160-LOCAL TEST_RESULT test_bbsmncache_3_testseq()
162+LOCAL UNITTEST_RESULT test_bbsmncache_3_testseq()
161163 {
162164 bbsmncache_t *cache;
163- TEST_RESULT result = TEST_RESULT_PASS;
165+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
164166 UB *header;
165167 W header_len;
166168
@@ -169,11 +171,11 @@
169171 bbsmncache_getlatestheader(cache, &header, &header_len);
170172 if (header != NULL) {
171173 printf("bbsmncache_getlatestheader: data error\n");
172- result = TEST_RESULT_FAIL;
174+ result = UNITTEST_RESULT_FAIL;
173175 }
174176 if (header_len != 0) {
175177 printf("bbsmncache_getlatestheader: length error\n");
176- result = TEST_RESULT_FAIL;
178+ result = UNITTEST_RESULT_FAIL;
177179 }
178180
179181 bbsmncache_delete(cache);
@@ -181,7 +183,7 @@
181183 return result;
182184 }
183185
184-LOCAL TEST_RESULT test_bbsmncache_3()
186+LOCAL UNITTEST_RESULT test_bbsmncache_3()
185187 {
186188 return test_bbsmncache_3_testseq();
187189 }
@@ -188,12 +190,12 @@
188190
189191 /* test_bbsmncache_4 */
190192
191-LOCAL TEST_RESULT test_bbsmncache_4_testseq()
193+LOCAL UNITTEST_RESULT test_bbsmncache_4_testseq()
192194 {
193195 W err;
194196 bbsmncache_t *cache;
195197 bbsmncache_datareadcontext_t *context;
196- TEST_RESULT result = TEST_RESULT_PASS;
198+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
197199 Bool ok;
198200
199201 cache = bbsmncache_new();
@@ -202,25 +204,25 @@
202204 if (err < 0) {
203205 printf("bbsmncache_appenddata error 1\n");
204206 bbsmncache_delete(cache);
205- return TEST_RESULT_FAIL;
207+ return UNITTEST_RESULT_FAIL;
206208 }
207209 err = bbsmncache_appenddata(cache, test_bbsmncache_testdata_01_2, strlen(test_bbsmncache_testdata_01_2));
208210 if (err < 0) {
209211 printf("bbsmncache_appenddata error 2\n");
210212 bbsmncache_delete(cache);
211- return TEST_RESULT_FAIL;
213+ return UNITTEST_RESULT_FAIL;
212214 }
213215 err = bbsmncache_appenddata(cache, test_bbsmncache_testdata_01_3, strlen(test_bbsmncache_testdata_01_3));
214216 if (err < 0) {
215217 printf("bbsmncache_appenddata error 3\n");
216218 bbsmncache_delete(cache);
217- return TEST_RESULT_FAIL;
219+ return UNITTEST_RESULT_FAIL;
218220 }
219221 err = bbsmncache_appenddata(cache, test_bbsmncache_testdata_01_4, strlen(test_bbsmncache_testdata_01_4));
220222 if (err < 0) {
221223 printf("bbsmncache_appenddata error 4\n");
222224 bbsmncache_delete(cache);
223- return TEST_RESULT_FAIL;
225+ return UNITTEST_RESULT_FAIL;
224226 }
225227
226228 context = bbsmncache_startdataread(cache, 0);
@@ -227,11 +229,11 @@
227229 if (context == NULL) {
228230 printf("bbsmncache_startdataread error\n");
229231 bbsmncache_delete(cache);
230- return TEST_RESULT_FAIL;
232+ return UNITTEST_RESULT_FAIL;
231233 }
232234 ok = test_bbsmncache_util_cmp_ctx_str(context, test_bbsmncache_testdata_01, strlen(test_bbsmncache_testdata_01));
233235 if (ok != True) {
234- result = TEST_RESULT_FAIL;
236+ result = UNITTEST_RESULT_FAIL;
235237 }
236238 bbsmncache_enddataread(cache, context);
237239
@@ -240,7 +242,7 @@
240242 return result;
241243 }
242244
243-LOCAL TEST_RESULT test_bbsmncache_4()
245+LOCAL UNITTEST_RESULT test_bbsmncache_4()
244246 {
245247 return test_bbsmncache_4_testseq();
246248 }
@@ -247,12 +249,12 @@
247249
248250 /* test_bbsmncache_5 */
249251
250-LOCAL TEST_RESULT test_bbsmncache_5_testseq()
252+LOCAL UNITTEST_RESULT test_bbsmncache_5_testseq()
251253 {
252254 W err;
253255 bbsmncache_t *cache;
254256 bbsmncache_datareadcontext_t *context;
255- TEST_RESULT result = TEST_RESULT_PASS;
257+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
256258 UB *bin_cache;
257259 W len_cache;
258260 Bool ok;
@@ -263,35 +265,35 @@
263265 if (err < 0) {
264266 printf("bbsmncache_appenddata error 1\n");
265267 bbsmncache_delete(cache);
266- return TEST_RESULT_FAIL;
268+ return UNITTEST_RESULT_FAIL;
267269 }
268270 err = bbsmncache_appenddata(cache, test_bbsmncache_testdata_01_2, strlen(test_bbsmncache_testdata_01_2));
269271 if (err < 0) {
270272 printf("bbsmncache_appenddata error 2\n");
271273 bbsmncache_delete(cache);
272- return TEST_RESULT_FAIL;
274+ return UNITTEST_RESULT_FAIL;
273275 }
274276 err = bbsmncache_appenddata(cache, test_bbsmncache_testdata_01_3, strlen(test_bbsmncache_testdata_01_3));
275277 if (err < 0) {
276278 printf("bbsmncache_appenddata error 3\n");
277279 bbsmncache_delete(cache);
278- return TEST_RESULT_FAIL;
280+ return UNITTEST_RESULT_FAIL;
279281 }
280282 err = bbsmncache_appenddata(cache, test_bbsmncache_testdata_01_4, strlen(test_bbsmncache_testdata_01_4));
281283 if (err < 0) {
282284 printf("bbsmncache_appenddata error 4\n");
283285 bbsmncache_delete(cache);
284- return TEST_RESULT_FAIL;
286+ return UNITTEST_RESULT_FAIL;
285287 }
286288
287289 context = bbsmncache_startdataread(cache, strlen(test_bbsmncache_testdata_01)+5);
288290 if (context == NULL) {
289291 bbsmncache_delete(cache);
290- return TEST_RESULT_FAIL;
292+ return UNITTEST_RESULT_FAIL;
291293 }
292294 ok = bbsmncache_datareadcontext_nextdata(context, &bin_cache, &len_cache);
293295 if (ok == True) {
294- result = TEST_RESULT_FAIL;
296+ result = UNITTEST_RESULT_FAIL;
295297 }
296298 bbsmncache_enddataread(cache, context);
297299
@@ -300,31 +302,16 @@
300302 return result;
301303 }
302304
303-LOCAL TEST_RESULT test_bbsmncache_5()
305+LOCAL UNITTEST_RESULT test_bbsmncache_5()
304306 {
305307 return test_bbsmncache_5_testseq();
306308 }
307309
308-LOCAL VOID test_bbsmncache_printresult(TEST_RESULT (*proc)(), B *test_name)
310+EXPORT VOID test_bbsmncache_main(unittest_driver_t *driver)
309311 {
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);
321317 }
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-}
--- bchanl/trunk/src/test_main.c (revision 419)
+++ bchanl/trunk/src/test_main.c (revision 420)
@@ -27,18 +27,32 @@
2727 #include <basic.h>
2828 #include <btron/btron.h>
2929
30+#include <unittest_driver.h>
31+
3032 #include "test.h"
3133
3234 EXPORT W MAIN(MESSAGE *msg)
3335 {
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;
4237
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+
4357 return 0;
4458 }
--- bchanl/trunk/src/test.h (revision 419)
+++ bchanl/trunk/src/test.h (revision 420)
@@ -25,37 +25,33 @@
2525 */
2626
2727 #include <basic.h>
28+#include <unittest_driver.h>
2829
2930 #ifndef __BCHANL_TEST_H__
3031 #define __BCHANL_TEST_H__
3132
32-typedef enum {
33- TEST_RESULT_PASS,
34- TEST_RESULT_FAIL
35-} TEST_RESULT;
36-
3733 /* test_subjectcache.c */
38-IMPORT VOID test_sbjtcache_main();
34+IMPORT VOID test_sbjtcache_main(unittest_driver_t *driver);
3935
4036 /* test_subjectparser.c */
41-IMPORT VOID test_sbjtparser_main();
37+IMPORT VOID test_sbjtparser_main(unittest_driver_t *driver);
4238
4339 /* test_subjectlist.c */
44-IMPORT VOID test_sbjtlist_main();
40+IMPORT VOID test_sbjtlist_main(unittest_driver_t *driver);
4541
4642 /* test_subjectlayout.c */
47-IMPORT VOID test_sbjtlayout_main();
43+IMPORT VOID test_sbjtlayout_main(unittest_driver_t *driver);
4844
4945 /* test_bbsmenucache.c */
50-IMPORT VOID test_bbsmncache_main();
46+IMPORT VOID test_bbsmncache_main(unittest_driver_t *driver);
5147
5248 /* test_bbsmenuparser.c */
53-IMPORT VOID test_bbsmnparser_main();
49+IMPORT VOID test_bbsmnparser_main(unittest_driver_t *driver);
5450
5551 /* test_bbsmenulayout.c */
56-IMPORT VOID test_bbsmnlayout_main();
52+IMPORT VOID test_bbsmnlayout_main(unittest_driver_t *driver);
5753
5854 /* test_bbsmenufilter.c */
59-IMPORT VOID test_bbsmnfilter_main();
55+IMPORT VOID test_bbsmnfilter_main(unittest_driver_t *driver);
6056
6157 #endif
--- bchanl/trunk/src/test_subjectlist.c (revision 419)
+++ bchanl/trunk/src/test_subjectlist.c (revision 420)
@@ -1,7 +1,7 @@
11 /*
22 * test_subjectlist.c
33 *
4- * Copyright (c) 2011 project bchan
4+ * Copyright (c) 2011-2012 project bchan
55 *
66 * This software is provided 'as-is', without any express or implied
77 * warranty. In no event will the authors be held liable for any damages
@@ -24,6 +24,10 @@
2424 *
2525 */
2626
27+#include "test.h"
28+
29+#include "subjectlist.h"
30+
2731 #include <btron/btron.h>
2832 #include <btron/dp.h>
2933 #include <tcode.h>
@@ -32,9 +36,8 @@
3236 #include <bstdlib.h>
3337 #include <tstring.h>
3438
35-#include "test.h"
39+#include <unittest_driver.h>
3640
37-#include "subjectlist.h"
3841 #include "subjectparser.h"
3942 #include "subjectcache.h"
4043
@@ -83,7 +86,7 @@
8386 };
8487 typedef struct testsbjtlist_expected_t_ testsbjtlist_expected_t;
8588
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)
8790 {
8891 W err, num, len, i;
8992 Bool next;
@@ -94,7 +97,7 @@
9497 sbjtcache_t *cache;
9598 sbjtparser_t *parser;
9699 sbjtparser_thread_t *thread = NULL;
97- TEST_RESULT result = TEST_RESULT_PASS;
100+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
98101
99102 cache = sbjtcache_new();
100103 sbjtcache_appenddata(cache, testdata, testdata_len);
@@ -123,28 +126,28 @@
123126 break;
124127 }
125128 if (i >= expected_len) {
126- result = TEST_RESULT_FAIL;
129+ result = UNITTEST_RESULT_FAIL;
127130 break;
128131 }
129132 sbjtlist_tuple_gettitle(tuple, &title, &len);
130133 sbjtlist_tuple_getnumber(tuple, &num);
131134 if (expected[i].num != num) {
132- result = TEST_RESULT_FAIL;
135+ result = UNITTEST_RESULT_FAIL;
133136 break;
134137 }
135138 if (expected[i].title_len != len) {
136- result = TEST_RESULT_FAIL;
139+ result = UNITTEST_RESULT_FAIL;
137140 break;
138141 }
139142 if (tc_strncmp(title, expected[i].title, len) != 0) {
140- result = TEST_RESULT_FAIL;
143+ result = UNITTEST_RESULT_FAIL;
141144 break;
142145 }
143146 }
144147 sbjtlist_endread(list, list_iter);
145148
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;
148151 }
149152
150153 sbjtlist_delete(list);
@@ -155,7 +158,7 @@
155158 return result;
156159 }
157160
158-LOCAL TEST_RESULT test_sbjtlist_1()
161+LOCAL UNITTEST_RESULT test_sbjtlist_1()
159162 {
160163 testsbjtlist_expected_t expected[] = {
161164 {
@@ -182,7 +185,7 @@
182185 return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_NUMBER, False, NULL, 0, expected, sizeof(expected));
183186 }
184187
185-LOCAL TEST_RESULT test_sbjtlist_2()
188+LOCAL UNITTEST_RESULT test_sbjtlist_2()
186189 {
187190 testsbjtlist_expected_t expected[] = {
188191 {
@@ -209,7 +212,7 @@
209212 return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_RES, False, NULL, 0, expected, sizeof(expected));
210213 }
211214
212-LOCAL TEST_RESULT test_sbjtlist_3()
215+LOCAL UNITTEST_RESULT test_sbjtlist_3()
213216 {
214217 testsbjtlist_expected_t expected[] = {
215218 {
@@ -236,7 +239,7 @@
236239 return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_SINCE, False, NULL, 0, expected, sizeof(expected));
237240 }
238241
239-LOCAL TEST_RESULT test_sbjtlist_4()
242+LOCAL UNITTEST_RESULT test_sbjtlist_4()
240243 {
241244 testsbjtlist_expected_t expected[] = {
242245 {
@@ -263,7 +266,7 @@
263266 return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_VIGOR, False, NULL, 0, expected, sizeof(expected));
264267 }
265268
266-LOCAL TEST_RESULT test_sbjtlist_5()
269+LOCAL UNITTEST_RESULT test_sbjtlist_5()
267270 {
268271 testsbjtlist_expected_t expected[] = {
269272 {
@@ -290,7 +293,7 @@
290293 return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_NUMBER, True, NULL, 0, expected, sizeof(expected));
291294 }
292295
293-LOCAL TEST_RESULT test_sbjtlist_6()
296+LOCAL UNITTEST_RESULT test_sbjtlist_6()
294297 {
295298 testsbjtlist_expected_t expected[] = {
296299 {
@@ -317,7 +320,7 @@
317320 return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_RES, True, NULL, 0, expected, sizeof(expected));
318321 }
319322
320-LOCAL TEST_RESULT test_sbjtlist_7()
323+LOCAL UNITTEST_RESULT test_sbjtlist_7()
321324 {
322325 testsbjtlist_expected_t expected[] = {
323326 {
@@ -344,7 +347,7 @@
344347 return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_SINCE, True, NULL, 0, expected, sizeof(expected));
345348 }
346349
347-LOCAL TEST_RESULT test_sbjtlist_8()
350+LOCAL UNITTEST_RESULT test_sbjtlist_8()
348351 {
349352 testsbjtlist_expected_t expected[] = {
350353 {
@@ -371,7 +374,7 @@
371374 return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_VIGOR, True, NULL, 0, expected, sizeof(expected));
372375 }
373376
374-LOCAL TEST_RESULT test_sbjtlist_9()
377+LOCAL UNITTEST_RESULT test_sbjtlist_9()
375378 {
376379 testsbjtlist_expected_t expected[] = {
377380 {
@@ -384,7 +387,7 @@
384387 return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_NUMBER, False, filter, tc_strlen(filter), expected, sizeof(expected));
385388 }
386389
387-LOCAL TEST_RESULT test_sbjtlist_10()
390+LOCAL UNITTEST_RESULT test_sbjtlist_10()
388391 {
389392 testsbjtlist_expected_t expected[] = {
390393 {
@@ -397,7 +400,7 @@
397400 return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_NUMBER, False, filter, tc_strlen(filter), expected, sizeof(expected));
398401 }
399402
400-LOCAL TEST_RESULT test_sbjtlist_11()
403+LOCAL UNITTEST_RESULT test_sbjtlist_11()
401404 {
402405 testsbjtlist_expected_t expected[] = {
403406 {
@@ -415,7 +418,7 @@
415418 return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_NUMBER, False, filter, tc_strlen(filter), expected, sizeof(expected));
416419 }
417420
418-LOCAL TEST_RESULT test_sbjtlist_12()
421+LOCAL UNITTEST_RESULT test_sbjtlist_12()
419422 {
420423 testsbjtlist_expected_t expected[] = {
421424 {
@@ -428,7 +431,7 @@
428431 return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_NUMBER, False, filter, tc_strlen(filter), expected, sizeof(expected));
429432 }
430433
431-LOCAL TEST_RESULT test_sbjtlist_13()
434+LOCAL UNITTEST_RESULT test_sbjtlist_13()
432435 {
433436 testsbjtlist_expected_t expected[] = {
434437 };
@@ -436,7 +439,7 @@
436439 return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_NUMBER, False, filter, tc_strlen(filter), expected, sizeof(expected));
437440 }
438441
439-LOCAL TEST_RESULT test_sbjtlist_14()
442+LOCAL UNITTEST_RESULT test_sbjtlist_14()
440443 {
441444 testsbjtlist_expected_t expected[] = {
442445 };
@@ -444,35 +447,20 @@
444447 return test_sbjtlist_checksort(test_sbjtlist_testdata_01, strlen(test_sbjtlist_testdata_01), SBJTLIST_SORTBY_NUMBER, False, filter, tc_strlen(filter), expected, sizeof(expected));
445448 }
446449
447-LOCAL VOID test_sbjtlist_printresult(TEST_RESULT (*proc)(), B *test_name)
450+EXPORT VOID test_sbjtlist_main(unittest_driver_t *driver)
448451 {
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);
460466 }
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-}
--- bchanl/trunk/src/test_subjectlayout.c (revision 419)
+++ bchanl/trunk/src/test_subjectlayout.c (revision 420)
@@ -1,7 +1,7 @@
11 /*
22 * test_subjectlayout.c
33 *
4- * Copyright (c) 2009-2011 project bchan
4+ * Copyright (c) 2009-2012 project bchan
55 *
66 * This software is provided 'as-is', without any express or implied
77 * warranty. In no event will the authors be held liable for any damages
@@ -24,6 +24,10 @@
2424 *
2525 */
2626
27+#include "test.h"
28+
29+#include "subjectlayout.h"
30+
2731 #include <btron/btron.h>
2832 #include <btron/dp.h>
2933 #include <tcode.h>
@@ -31,9 +35,8 @@
3135 #include <bstring.h>
3236 #include <bstdlib.h>
3337
34-#include "test.h"
38+#include <unittest_driver.h>
3539
36-#include "subjectlayout.h"
3740 #include "subjectlist.h"
3841 #include "subjectparser.h"
3942 #include "subjectcache.h"
@@ -95,7 +98,7 @@
9598 free(bmp);
9699 }
97100
98-LOCAL TEST_RESULT test_sbjtlayout_1()
101+LOCAL UNITTEST_RESULT test_sbjtlayout_1()
99102 {
100103 BMP *bmp;
101104 GID gid;
@@ -108,15 +111,15 @@
108111 sbjtcache_t *cache;
109112 sbjtparser_t *parser;
110113 sbjtparser_thread_t *thread = NULL;
111- TEST_RESULT result = TEST_RESULT_PASS;
114+ UNITTEST_RESULT result = UNITTEST_RESULT_PASS;
112115
113116 bmp = test_sbjtlayout_util_alloc_BMP();
114117 if (bmp == NULL) {
115- return TEST_RESULT_FAIL;
118+ return UNITTEST_RESULT_FAIL;
116119 }
117120 gid = gopn_mem(NULL, bmp, NULL);
118121 if (gid < 0) {
119- return TEST_RESULT_FAIL;
122+ return UNITTEST_RESULT_FAIL;
120123 }
121124
122125 cache = sbjtcache_new();
@@ -162,22 +165,7 @@
162165 return result;
163166 }
164167
165-LOCAL VOID test_sbjtlayout_printresult(TEST_RESULT (*proc)(), B *test_name)
168+EXPORT VOID test_sbjtlayout_main(unittest_driver_t *driver)
166169 {
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);
178171 }
179-
180-EXPORT VOID test_sbjtlayout_main()
181-{
182- test_sbjtlayout_printresult(test_sbjtlayout_1, "test_sbjtlayout_1");
183-}
Show on old repository browser