Changeset 585 for trunk/src/tests
- Timestamp:
- 09/28/07 12:14:38 (1 year ago)
- Files:
-
- trunk/src/tests/sample.c (added)
- trunk/src/tests/z-file.c (modified) (3 diffs)
- trunk/src/tests/z-file.mk (modified) (1 diff)
- trunk/src/tests/z-tests.c (added)
- trunk/src/tests/z-tests.mk (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/tests/z-file.c
r469 r585 14 14 #include <stdio.h> 15 15 #include "../z-file.h" 16 17 /*** Hacky basic test structure ***/ 18 19 typedef struct 20 { 21 unsigned num_tests; 22 unsigned num_tests_failed; 23 } test_stats; 24 25 typedef int (*test_func)(void); 26 27 void test_run(test_stats *stats, const char *name, test_func tester) 28 { 29 stats->num_tests++; 30 printf("running test %s... ", name); 31 32 if ((*tester)() == 0) 33 { 34 stats->num_tests_failed++; 35 printf("FAIL\n"); 36 } 37 else 38 { 39 printf("successful\n"); 40 } 41 } 42 43 void test_summarise(test_stats *stats) 44 { 45 printf("%d tests\n", stats->num_tests); 46 printf("%d failed\n", stats->num_tests_failed); 47 } 48 49 int test_success(test_stats *stats) 50 { 51 return (stats->num_tests_failed) ? 1 : 0; 52 } 53 54 #define TEST_RUN(stat, test) test_run(stat, #test, test_##test) 55 56 #define TEST(x) static int test_##x(void) { 57 #define TEST_END return 1; } 58 59 #define FAIL return 0; 60 61 62 16 #include "../z-tests.h" 63 17 /*** z-file tests ***/ 64 18 … … 356 310 int main(void) 357 311 { 358 test_stats test = { 0, 0 };312 TEST_PLAN(test, 10); 359 313 360 314 TEST_RUN(&test, file_open); … … 370 324 TEST_RUN(&test, path_build); 371 325 372 test_summarise(&test); 373 374 return test_success(&test) ? 0 : 1; 375 } 326 TESTS_COMPLETE(test); 327 } trunk/src/tests/z-file.mk
r469 r585 6 6 LDFLAGS = -fprofile-arcs -ftest-coverage 7 7 8 OBJS = z-file.o ../z- file.o ../z-virt.o ../z-util.o ../z-form.o8 OBJS = z-file.o ../z-tests.o ../z-file.o ../z-virt.o ../z-util.o ../z-form.o 9 9 10 10 $(EXE): $(OBJS)
