diff options
| author | Tyge Løvset <[email protected]> | 2023-01-21 20:20:24 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-01-21 20:20:24 +0100 |
| commit | 2c5d525fa939cad8c50903f24b7ecc95ebfc4a87 (patch) | |
| tree | 74dbdbf48039fcc5b8b60a68f92aa83573b91f3f | |
| parent | 0197ade3ef8a2e89a466f5a1c3e512363752879b (diff) | |
| download | STC-modified-2c5d525fa939cad8c50903f24b7ecc95ebfc4a87.tar.gz STC-modified-2c5d525fa939cad8c50903f24b7ecc95ebfc4a87.zip | |
Corrected the names of float/double ctest functions to match GoogleTest
| -rw-r--r-- | misc/tests/ctest.h | 12 | ||||
| -rw-r--r-- | misc/tests/mytests.c.txt | 14 |
2 files changed, 13 insertions, 13 deletions
diff --git a/misc/tests/ctest.h b/misc/tests/ctest.h index 29eb151e..483a05d7 100644 --- a/misc/tests/ctest.h +++ b/misc/tests/ctest.h @@ -225,15 +225,15 @@ void assert_fail(const char* caller, int line); #define ASSERT_FAIL() assert_fail(__FILE__, __LINE__) void assert_dbl_compare(const char* cmp, double exp, double real, double tol, const char* caller, int line); -#define ASSERT_DOUBLE_NEAR(exp, real) assert_dbl_compare("==", exp, real, -CTEST_DBL_EPSILON, __FILE__, __LINE__) -#define ASSERT_DOUBLE_NEAR_TOL(exp, real, tol) assert_dbl_compare("==", exp, real, tol, __FILE__, __LINE__) -#define ASSERT_DOUBLE_NOTNEAR(exp, real) assert_dbl_compare("!=", exp, real, -CTEST_DBL_EPSILON, __FILE__, __LINE__) -#define ASSERT_DOUBLE_NOTNEAR_TOL(exp, real, tol) assert_dbl_compare("!=", exp, real, tol, __FILE__, __LINE__) +#define ASSERT_NEAR(exp, real, tol) assert_dbl_compare("==", exp, real, tol, __FILE__, __LINE__) +#define ASSERT_NOTNEAR(exp, real, tol) assert_dbl_compare("!=", exp, real, tol, __FILE__, __LINE__) +#define ASSERT_DOUBLE_EQ(exp, real) assert_dbl_compare("==", exp, real, -CTEST_DBL_EPSILON, __FILE__, __LINE__) +#define ASSERT_DOUBLE_NE(exp, real) assert_dbl_compare("!=", exp, real, -CTEST_DBL_EPSILON, __FILE__, __LINE__) #define ASSERT_DOUBLE_LT(v1, v2) assert_dbl_compare("<", v1, v2, 0.0, __FILE__, __LINE__) #define ASSERT_DOUBLE_GT(v1, v2) assert_dbl_compare(">", v1, v2, 0.0, __FILE__, __LINE__) -#define ASSERT_FLOAT_NEAR(v1, v2) assert_dbl_compare("==", v1, v2, -CTEST_FLT_EPSILON, __FILE__, __LINE__) -#define ASSERT_FLOAT_NOTNEAR(v1, v2) assert_dbl_compare("!=", v1, v2, -CTEST_FLT_EPSILON, __FILE__, __LINE__) +#define ASSERT_FLOAT_EQ(v1, v2) assert_dbl_compare("==", v1, v2, -CTEST_FLT_EPSILON, __FILE__, __LINE__) +#define ASSERT_FLOAT_NE(v1, v2) assert_dbl_compare("!=", v1, v2, -CTEST_FLT_EPSILON, __FILE__, __LINE__) #define ASSERT_FLOAT_LT(v1, v2) assert_dbl_compare("<", (float)(v1), (float)(v2), 0.0, __FILE__, __LINE__) #define ASSERT_FLOAT_GT(v1, v2) assert_dbl_compare(">", (float)(v1), (float)(v2), 0.0, __FILE__, __LINE__) diff --git a/misc/tests/mytests.c.txt b/misc/tests/mytests.c.txt index 71824d14..47db05e3 100644 --- a/misc/tests/mytests.c.txt +++ b/misc/tests/mytests.c.txt @@ -197,18 +197,18 @@ CTEST(ctest, test_ctest_err) { CTEST(ctest, test_dbl_near) { double a = 0.000111; - ASSERT_DOUBLE_NEAR(0.0001, a); + ASSERT_DOUBLE_EQ(0.0001, a); } CTEST(ctest, test_dbl_near_tol) { double a = 0.000111; - ASSERT_DOUBLE_NEAR_TOL(0.0001, a, 1e-5); /* will fail */ + ASSERT_NEAR(0.0001, a, 1e-5); /* will fail */ } CTEST(ctest, test_dbl_far) { double a = 1.1; - ASSERT_DOUBLE_NOTNEAR(1., a); - ASSERT_DOUBLE_NOTNEAR_TOL(1., a, 0.01); + ASSERT_DOUBLE_NE(1., a); + ASSERT_NOTNEAR(1., a, 0.01); } CTEST(ctest, test_assert_compare) { @@ -219,9 +219,9 @@ CTEST(ctest, test_assert_compare) { CTEST(ctest, test_dbl_near2) { float a = 0.000001000003f; - ASSERT_FLOAT_NEAR(0.000001f, a); /* ok, uses float epsilon -1e-5 */ - ASSERT_DOUBLE_NEAR_TOL(0.000001, a, -1e-5); /* ok, tol < 0 = relative err (epsilon) */ - ASSERT_DOUBLE_NEAR(0.000001, a); /* fail, tol = -1e-12 (epsilon) */ + ASSERT_FLOAT_EQ(0.000001f, a); /* ok, uses float epsilon -1e-5 */ + ASSERT_NEAR(0.000001, a, -1e-5); /* ok, tol < 0 = relative err (epsilon) */ + ASSERT_DOUBLE_EQ(0.000001, a); /* fail, tol = -1e-12 (epsilon) */ } CTEST(ctest, test_dbl_compare) { |
