diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-12-28 16:05:42 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-12-28 16:05:42 -0800 |
commit | 11a29f6219ab9c72c0863e47ba386d7b3e1162d5 (patch) | |
tree | 7811d042876a5e6061e5543e48ec2e42f75e8aa5 /api_test/harness.c | |
parent | c22b173c1fee932a9469f95c71f74a9ec0ca1784 (diff) |
Reformat sources.
Diffstat (limited to 'api_test/harness.c')
-rw-r--r-- | api_test/harness.c | 139 |
1 files changed, 60 insertions, 79 deletions
diff --git a/api_test/harness.c b/api_test/harness.c index e8f320c..f6fd0bc 100644 --- a/api_test/harness.c +++ b/api_test/harness.c @@ -5,98 +5,79 @@ #include "harness.h" -test_batch_runner* -test_batch_runner_new() -{ - return (test_batch_runner *)calloc(1, sizeof(test_batch_runner)); +test_batch_runner *test_batch_runner_new() { + return (test_batch_runner *)calloc(1, sizeof(test_batch_runner)); } -static void -test_result(test_batch_runner *runner, int cond, const char *msg, va_list ap) -{ - ++runner->test_num; - - if (cond) { - ++runner->num_passed; - } - else { - fprintf(stderr, "FAILED test %d: ", runner->test_num); - vfprintf(stderr, msg, ap); - fprintf(stderr, "\n"); - ++runner->num_failed; - } +static void test_result(test_batch_runner *runner, int cond, const char *msg, + va_list ap) { + ++runner->test_num; + + if (cond) { + ++runner->num_passed; + } else { + fprintf(stderr, "FAILED test %d: ", runner->test_num); + vfprintf(stderr, msg, ap); + fprintf(stderr, "\n"); + ++runner->num_failed; + } } -void -SKIP(test_batch_runner *runner, int num_tests) -{ - runner->test_num += num_tests; - runner->num_skipped += num_tests; +void SKIP(test_batch_runner *runner, int num_tests) { + runner->test_num += num_tests; + runner->num_skipped += num_tests; } -void -OK(test_batch_runner *runner, int cond, const char *msg, ...) -{ - va_list ap; - va_start(ap, msg); - test_result(runner, cond, msg, ap); - va_end(ap); +void OK(test_batch_runner *runner, int cond, const char *msg, ...) { + va_list ap; + va_start(ap, msg); + test_result(runner, cond, msg, ap); + va_end(ap); } -void -INT_EQ(test_batch_runner *runner, int got, int expected, const char *msg, ...) -{ - int cond = got == expected; +void INT_EQ(test_batch_runner *runner, int got, int expected, const char *msg, + ...) { + int cond = got == expected; - va_list ap; - va_start(ap, msg); - test_result(runner, cond, msg, ap); - va_end(ap); + va_list ap; + va_start(ap, msg); + test_result(runner, cond, msg, ap); + va_end(ap); - if (!cond) { - fprintf(stderr, " Got: %d\n", got); - fprintf(stderr, " Expected: %d\n", expected); - } + if (!cond) { + fprintf(stderr, " Got: %d\n", got); + fprintf(stderr, " Expected: %d\n", expected); + } } -void -STR_EQ(test_batch_runner *runner, const char *got, const char *expected, - const char *msg, ...) -{ - int cond = strcmp(got, expected) == 0; - - va_list ap; - va_start(ap, msg); - test_result(runner, cond, msg, ap); - va_end(ap); - - if (!cond) { - fprintf(stderr, " Got: \"%s\"\n", got); - fprintf(stderr, " Expected: \"%s\"\n", expected); - } -} +void STR_EQ(test_batch_runner *runner, const char *got, const char *expected, + const char *msg, ...) { + int cond = strcmp(got, expected) == 0; -int -test_ok(test_batch_runner *runner) -{ - return runner->num_failed == 0; -} + va_list ap; + va_start(ap, msg); + test_result(runner, cond, msg, ap); + va_end(ap); -void -test_print_summary(test_batch_runner *runner) -{ - int num_passed = runner->num_passed; - int num_skipped = runner->num_skipped; - int num_failed = runner->num_failed; - - fprintf(stderr, "%d tests passed, %d failed, %d skipped\n", - num_passed, num_failed, num_skipped); - - if (test_ok(runner)) { - fprintf(stderr, "PASS\n"); - } - else { - fprintf(stderr, "FAIL\n"); - } + if (!cond) { + fprintf(stderr, " Got: \"%s\"\n", got); + fprintf(stderr, " Expected: \"%s\"\n", expected); + } } +int test_ok(test_batch_runner *runner) { return runner->num_failed == 0; } + +void test_print_summary(test_batch_runner *runner) { + int num_passed = runner->num_passed; + int num_skipped = runner->num_skipped; + int num_failed = runner->num_failed; + + fprintf(stderr, "%d tests passed, %d failed, %d skipped\n", num_passed, + num_failed, num_skipped); + + if (test_ok(runner)) { + fprintf(stderr, "PASS\n"); + } else { + fprintf(stderr, "FAIL\n"); + } +} |