diff options
| author | Garrett D'Amore <garrett@damore.org> | 2016-12-18 23:11:21 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2016-12-18 23:11:21 -0800 |
| commit | b73794d8cd48804685248f6f7d57b831841bd620 (patch) | |
| tree | c307424196edc95875508f10b097b7afb8f2aed5 | |
| parent | c6640e3bcfce9f3e3d4def60b0acb7ea782ab890 (diff) | |
| download | nng-b73794d8cd48804685248f6f7d57b831841bd620.tar.gz nng-b73794d8cd48804685248f6f7d57b831841bd620.tar.bz2 nng-b73794d8cd48804685248f6f7d57b831841bd620.zip | |
Minor bug fixes to test.h and co.
| -rw-r--r-- | tests/test.c | 24 | ||||
| -rw-r--r-- | tests/test.h | 21 |
2 files changed, 7 insertions, 38 deletions
diff --git a/tests/test.c b/tests/test.c index 81dfc58f..a133b677 100644 --- a/tests/test.c +++ b/tests/test.c @@ -403,30 +403,6 @@ test_i_assert_skip(const char *cond, const char *file, int line) t->t_name, file, line); } -void -test_i_assert_fatal(const char *cond, const char *file, int line) -{ - tctx_t *t = get_ctx(); - nasserts++; - if (verbose) { - (void) printf("%s%s%s", color_red, sym_fail, color_none); - } - if (t->t_root != t) { - t->t_root->t_fatal++; - } - color_asserts = color_red; - t->t_fail++; - t->t_done = 1; /* This forces an end */ - log_printf(t->t_fatallog, "* %s (Fatal Assertion Failed)\n", t->t_name); - log_printf(t->t_fatallog, "File: %s\n", file); - log_printf(t->t_fatallog, "Line: %d\n", line); - log_printf(t->t_fatallog, "Test: %s\n\n", cond); - log_printf(t->t_debuglog, "* %s (%s:%d) (FAILED)\n", - t->t_name, file, line); - - longjmp(*t->t_jmp, 1); -} - /* * Performance counters. Really we just want to start and stop timers, to * measure elapsed time in usec. diff --git a/tests/test.h b/tests/test.h index 454cb25d..28e13572 100644 --- a/tests/test.h +++ b/tests/test.h @@ -89,7 +89,6 @@ extern int test_i_main(int, char **); extern void test_i_assert_pass(const char *, const char *, int); extern void test_i_assert_skip(const char *, const char *, int); extern void test_i_assert_fail(const char *, const char *, int); -extern void test_i_assert_fatal(const char *, const char *, int); extern void test_i_skip(const char *, int, const char *); extern void test_i_fail(const char *, int, const char *); extern void test_i_fatal(const char *, int, const char *); @@ -175,7 +174,8 @@ extern void test_i_fatal(const char *, int, const char *); * memory in the test framework, and anything else indicates a * an error or failure in the code being tested. */ -#define test_block(T_name, T_code) test_i_run(T_name, T_code, NULL) +#define test_block(T_name, T_code, T_rvp) \ + test_i_run(T_name, T_code, T_rvp) /* * test_assert and test_so allow you to run assertions. @@ -183,21 +183,13 @@ extern void test_i_fatal(const char *, int, const char *); #define test_assert(T_cond) \ do { \ if (!(T_cond)) { \ - test_i_assert_fatal(#T_cond, __FILE__, __LINE__);\ - } else { \ - test_i_assert_pass(#T_cond, __FILE__, __LINE__);\ - } \ - } while (0) - -#define test_so(T_cond) \ - do { \ - if (!(T_cond)) { \ test_i_assert_fail(#T_cond, __FILE__, __LINE__);\ } else { \ test_i_assert_pass(#T_cond, __FILE__, __LINE__);\ } \ } while (0) +#define test_so(T_cond) test_assert(T_cond) /* * test_convey(name, <code>) starts a convey context, with <code> as @@ -216,10 +208,11 @@ extern void test_i_fatal(const char *, int, const char *); #define test_fatal(reason) test_i_fatal(__FILE__, __LINE__, reason) /* - * test_skip_assert() is used to skip processing of a single assertion. + * test_skip_so() is used to skip processing of a single assertion. * Further processing in the same context continues. */ -#define test_skip_assert(T_cnd) test_i_assert_skip(T_cnd) +#define test_skip_so(T_cnd) \ + test_i_assert_skip(T_cnd, __FILE__, __LINE__) /* * test_skip_convey() is used to skip a convey context. This is intended @@ -227,7 +220,7 @@ extern void test_i_fatal(const char *, int, const char *); * and the current convey context continues processing. */ #define test_skip_convey(T_name, T_code) \ - test_convey(T_name, test_skip()) + test_convey(T_name, test_skip("Skipped")) /* * test_reset establishes a reset for the current block. This code will |
