From 92f373bb676fa0b272ca2ac6091890f651377d01 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 3 Nov 2023 19:57:02 +0000 Subject: Increase BOOST_CHECK_CLOSE_VEC stream precision Spent way too long trying to explain a test failure because the precision of the debug didn't show the differences. --- test/testHelpers.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/testHelpers.h') diff --git a/test/testHelpers.h b/test/testHelpers.h index 54b7fc6..79e966a 100644 --- a/test/testHelpers.h +++ b/test/testHelpers.h @@ -2,6 +2,7 @@ #include #include +#include // IWYU pragma: keep std::setprecision #include std::unique_ptr uasprintf(const char * fmt, ...) __attribute__((format(printf, 1, 2))); @@ -9,7 +10,7 @@ std::unique_ptr uasprintf(const char * fmt, ...) __attrib #define BOOST_CHECK_CLOSE_VEC(a_, b_) \ { \ const auto a {a_}, b {b_}; \ - BOOST_TEST_CONTEXT("BOOST_CHECK_CLOSE_VEC(" << a << ", " << b << ")") { \ + BOOST_TEST_CONTEXT("BOOST_CHECK_CLOSE_VEC(" << std::setprecision(8) << a << ", " << b << ")") { \ BOOST_CHECK_LT(glm::length(a - b), 0.1F); \ } \ } -- cgit v1.2.3 From 504d345e24e3be54d90f8bdd107c5bfbb38e57af Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 9 Dec 2023 12:04:07 +0000 Subject: Helper for testing integer vector approximations --- test/testHelpers.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/testHelpers.h') 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 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_}; \ -- cgit v1.2.3