diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2012-12-18 12:44:23 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2012-12-18 12:45:06 -0500 |
commit | 330ead5f47a7c4904cc6cecfa36b10d75718f1ff (patch) | |
tree | 66e98fcc24633141b178557d0565996bda4915e8 /libdimension/tests/tests.h | |
parent | 5e45a00b8f67281b2977c41625ed57a4caa7d341 (diff) | |
download | dimension-330ead5f47a7c4904cc6cecfa36b10d75718f1ff.tar.xz |
Convert the polynomial tests to the new testing framework.
Diffstat (limited to 'libdimension/tests/tests.h')
-rw-r--r-- | libdimension/tests/tests.h | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/libdimension/tests/tests.h b/libdimension/tests/tests.h index 38d9107..3009164 100644 --- a/libdimension/tests/tests.h +++ b/libdimension/tests/tests.h @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> * + * Copyright (C) 2009-2012 Tavian Barnes <tavianator@tavianator.com> * * * * This file is part of The Dimension Test Suite. * * * @@ -21,12 +21,54 @@ #define TESTS_H #include "dimension.h" +#include <check.h> #ifdef __cplusplus /* We've been included from a C++ file; mark everything here as extern "C" */ extern "C" { #endif +/** @internal Map to known test cases from their names. */ +extern dmnsn_dictionary* dmnsn_test_cases; + +/** @internal Default test fixture. */ +void dmnsn_test_setup(void); +/** @internal Default test fixture. */ +void dmnsn_test_teardown(void); + +/** + * Mark the beginning of a test. + * @param[in] tcase The name of the test case for this test. + * @param[in] test The name of the test itself. + */ +#define DMNSN_TEST(tcase, test) \ + static void dmnsn_test_##test(int _i); \ + \ + __attribute__((constructor)) \ + static void dmnsn_add_test_##test(void) \ + { \ + if (dmnsn_test_cases == NULL) { \ + dmnsn_test_cases = dmnsn_new_dictionary(sizeof(TCase *)); \ + } \ + \ + TCase *tc; \ + TCase **tcp = dmnsn_dictionary_at(dmnsn_test_cases, tcase); \ + if (tcp == NULL) { \ + tc = tcase_create(tcase); \ + tcase_add_checked_fixture(tc, dmnsn_test_setup, dmnsn_test_teardown); \ + dmnsn_dictionary_insert(dmnsn_test_cases, tcase, &tc); \ + } else { \ + tc = *tcp; \ + } \ + \ + tcase_add_test(tc, dmnsn_test_##test); \ + } \ + \ + START_TEST(dmnsn_test_##test) + +/** Mark the end of a test. */ +#define DMNSN_END_TEST END_TEST + /* * Test canvas */ |