diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-08-14 21:11:24 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-08-14 21:11:24 +0000 |
commit | 4c30a83cbb022fd23d414473ac2d878e1f5b5d24 (patch) | |
tree | 8af1a8c73676f15056f887be8f2fdf1f11b5707b /test | |
parent | 91b3a453de03fa18eb6b10d663ac20dcf9022c77 (diff) |
Proper support for tests spannint multiple .o files
-Erik
Diffstat (limited to 'test')
-rw-r--r-- | test/testsuite.h | 88 |
1 files changed, 47 insertions, 41 deletions
diff --git a/test/testsuite.h b/test/testsuite.h index c80804b83..39d31d85b 100644 --- a/test/testsuite.h +++ b/test/testsuite.h @@ -24,15 +24,58 @@ #ifndef TESTSUITE_H #define TESTSUITE_H +#ifdef __NO_TESTCODE__ + +extern size_t test_number; + + +extern void init_testsuite(const char* testname); +extern void done_testing(void) __attribute__((noreturn)); +extern void success_msg(int result, const char* command); +extern void error_msg(int result, int line, const char* file, const char* command); + +#else + size_t test_number = 0; static int failures = 0; +void error_msg(int result, int line, const char* file, const char* command) +{ + failures++; + + printf("\nFAILED TEST %d: \n\t%s\n", test_number, command); + printf("AT LINE: %d, FILE: %s\n\n", line, file); +} + +void success_msg(int result, const char* command) +{ +#if 0 + printf("passed test: %s == 0\n", command); +#endif +} + +void done_testing(void) +{ + if (0 < failures) { + printf("Failed %d tests\n", failures); + exit(EXIT_FAILURE); + } else { + printf("All functions tested sucessfully\n"); + exit( EXIT_SUCCESS ); + } +} + +void init_testsuite(const char* testname) +{ + printf("%s", testname); + test_number = 0; + failures = 0; + atexit(done_testing); +} + +#endif -void init_testsuite(const char* testname); -void done_testing(void) __attribute__((noreturn)); -void success_msg(int result, const char* command); -void error_msg(int result, int line, const char* file, const char* command); #define TEST_STRING_OUTPUT( command, expected_result ) \ @@ -70,41 +113,4 @@ void error_msg(int result, int line, const char* file, const char* command); #define STR_CMD(cmd) cmd - - - -void error_msg(int result, int line, const char* file, const char* command) -{ - failures++; - - printf("\nFAILED TEST %d: \n\t%s\n", test_number, command); - printf("AT LINE: %d, FILE: %s\n\n", line, file); -} - -void success_msg(int result, const char* command) -{ -#if 0 - printf("passed test: %s == 0\n", command); -#endif -} - -void done_testing(void) -{ - if (0 < failures) { - printf("Failed %d tests\n", failures); - exit(EXIT_FAILURE); - } else { - printf("All functions tested sucessfully\n"); - exit( EXIT_SUCCESS ); - } -} - -void init_testsuite(const char* testname) -{ - printf("%s", testname); - test_number = 0; - failures = 0; - atexit(done_testing); -} - #endif /* TESTSUITE_H */ |