diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-12-09 12:04:07 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-12-09 12:04:07 +0000 |
commit | 504d345e24e3be54d90f8bdd107c5bfbb38e57af (patch) | |
tree | 6818f33a996f6c3aa23d219e8f2e7fcab4349529 | |
parent | Render test using loaded terrain (diff) | |
download | ilt-504d345e24e3be54d90f8bdd107c5bfbb38e57af.tar.bz2 ilt-504d345e24e3be54d90f8bdd107c5bfbb38e57af.tar.xz ilt-504d345e24e3be54d90f8bdd107c5bfbb38e57af.zip |
Helper for testing integer vector approximations
-rw-r--r-- | test/test-maths.cpp | 8 | ||||
-rw-r--r-- | test/testHelpers.h | 10 |
2 files changed, 14 insertions, 4 deletions
diff --git a/test/test-maths.cpp b/test/test-maths.cpp index 9eae918..cc97250 100644 --- a/test/test-maths.cpp +++ b/test/test-maths.cpp @@ -236,8 +236,8 @@ BOOST_DATA_TEST_CASE(curve1, } { const auto p = l.positionAt(0, 1); - BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, e1); - BOOST_CHECK_CLOSE_VEC(p.rot, glm::vec3(0, angBack, 0)); + BOOST_CHECK_CLOSE_VECI(RelativePosition3D {p.pos}, e1); + BOOST_CHECK_CLOSE_VECI(p.rot, glm::vec3(0, angBack, 0)); } } @@ -247,8 +247,8 @@ BOOST_DATA_TEST_CASE(curve1, { const auto p = l.positionAt(0, 0); const auto angForReversed = normalize(vector_yaw(origin - e1) * 2 - angFor); - BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, e1); - BOOST_CHECK_CLOSE_VEC(p.rot, glm::vec3(0, angForReversed, 0)); + BOOST_CHECK_CLOSE_VECI(RelativePosition3D {p.pos}, e1); + BOOST_CHECK_CLOSE_VECI(p.rot, glm::vec3(0, angForReversed, 0)); } { const auto p = l.positionAt(0, 1); diff --git a/test/testHelpers.h b/test/testHelpers.h index 79e966a..f2b0901 100644 --- a/test/testHelpers.h +++ b/test/testHelpers.h @@ -15,6 +15,16 @@ std::unique_ptr<char, decltype(&free)> uasprintf(const char * fmt, ...) __attrib } \ } +#define BOOST_CHECK_CLOSE_VECI(a_, b_) \ + { \ + const auto a {a_}, b {b_}; \ + BOOST_TEST_CONTEXT("BOOST_CHECK_CLOSE_VEC(" << std::setprecision(8) << a << ", " << b << ")") { \ + BOOST_CHECK_LE(std::abs(a.x - b.x), 1); \ + BOOST_CHECK_LE(std::abs(a.y - b.y), 1); \ + BOOST_CHECK_LE(std::abs(a.z - b.z), 1); \ + } \ + } + #define BOOST_CHECK_BETWEEN(a_, b_, c_) \ { \ const auto a {a_}, b {b_}, c {c_}; \ |