diff options
| author | Tyge Løvset <[email protected]> | 2023-01-24 12:50:11 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-01-24 12:50:11 +0100 |
| commit | deb412cb6c88187e9804c9aaf7f0427109479014 (patch) | |
| tree | 35353603f5306a35bff168e4b86bb944dadc1617 /misc/tests/ctest.h | |
| parent | c2d862f377f9bf2f276db7ba41ea835117603881 (diff) | |
| download | STC-modified-deb412cb6c88187e9804c9aaf7f0427109479014.tar.gz STC-modified-deb412cb6c88187e9804c9aaf7f0427109479014.zip | |
Small ctest enhancements
Diffstat (limited to 'misc/tests/ctest.h')
| -rw-r--r-- | misc/tests/ctest.h | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/misc/tests/ctest.h b/misc/tests/ctest.h index d50d8246..7edd41cc 100644 --- a/misc/tests/ctest.h +++ b/misc/tests/ctest.h @@ -210,16 +210,14 @@ void assert_interval(intmax_t low, intmax_t high, intmax_t real, const char* cal #define ASSERT_INTERVAL(low, high, real) assert_interval(low, high, real, __FILE__, __LINE__) void assert_pointers(const char* cmp, const void* exp, const void* real, const char* caller, int line); -#define ASSERT_NULL(real) assert_pointers("==", NULL, real, __FILE__, __LINE__) -#define ASSERT_NOT_NULL(real) assert_pointers("!=", NULL, real, __FILE__, __LINE__) #define ASSERT_PTR_EQ(exp, real) ((void)sizeof((exp) == (real)), assert_pointers("==", exp, real, __FILE__, __LINE__)) #define ASSERT_PTR_NE(exp, real) ((void)sizeof((exp) != (real)), assert_pointers("!=", exp, real, __FILE__, __LINE__)) +#define ASSERT_NULL(real) ASSERT_PTR_EQ(NULL, real) +#define ASSERT_NOT_NULL(real) ASSERT_PTR_NE(NULL, real) -void assert_true(int real, const char* caller, int line); -#define ASSERT_TRUE(real) assert_true(real, __FILE__, __LINE__) - -void assert_false(int real, const char* caller, int line); -#define ASSERT_FALSE(real) assert_false(real, __FILE__, __LINE__) +void assert_bool(bool exp, bool real, const char* caller, int line); +#define ASSERT_TRUE(real) assert_bool(true, real, __FILE__, __LINE__) +#define ASSERT_FALSE(real) assert_bool(false, real, __FILE__, __LINE__) void assert_fail(const char* caller, int line); #define ASSERT_FAIL() assert_fail(__FILE__, __LINE__) @@ -432,19 +430,13 @@ void assert_dbl_compare(const char* cmp, double exp, double real, double tol, co void assert_pointers(const char* cmp, const void* exp, const void* real, const char* caller, int line) { if ((exp == real) != (cmp[0] == '=')) { - CTEST_ERR("%s:%d pointer assertion failed %p %s %p", caller, line, exp, cmp, real); - } -} - -void assert_true(int real, const char* caller, int line) { - if ((real) == 0) { - CTEST_ERR("%s:%d should be true", caller, line); + CTEST_ERR("%s:%d assertion failed (0x%02llx) %s (0x%02llx)", caller, line, (unsigned long long)exp , cmp, (unsigned long long)real); } } -void assert_false(int real, const char* caller, int line) { - if ((real) != 0) { - CTEST_ERR("%s:%d should be false", caller, line); +void assert_bool(bool exp, bool real, const char* caller, int line) { + if (exp != real) { + CTEST_ERR("%s:%d should be %s", caller, line, exp ? "true" : "false"); } } |
