summaryrefslogtreecommitdiff
path: root/test/testHelpers.h
diff options
context:
space:
mode:
Diffstat (limited to 'test/testHelpers.h')
-rw-r--r--test/testHelpers.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/testHelpers.h b/test/testHelpers.h
new file mode 100644
index 0000000..54b7fc6
--- /dev/null
+++ b/test/testHelpers.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include <boost/test/tools/context.hpp>
+#include <boost/test/tools/interface.hpp>
+#include <memory>
+
+std::unique_ptr<char, decltype(&free)> uasprintf(const char * fmt, ...) __attribute__((format(printf, 1, 2)));
+
+#define BOOST_CHECK_CLOSE_VEC(a_, b_) \
+ { \
+ const auto a {a_}, b {b_}; \
+ BOOST_TEST_CONTEXT("BOOST_CHECK_CLOSE_VEC(" << a << ", " << b << ")") { \
+ BOOST_CHECK_LT(glm::length(a - b), 0.1F); \
+ } \
+ }
+
+#define BOOST_CHECK_BETWEEN(a_, b_, c_) \
+ { \
+ const auto a {a_}, b {b_}, c {c_}; \
+ BOOST_TEST_CONTEXT("BOOST_CHECK_BETWEEN(" << a << ", " << b << ", " << c << ")") { \
+ BOOST_CHECK_LE(b, a); \
+ BOOST_CHECK_GE(c, a); \
+ } \
+ }
+#define BOOST_REQUIRE_THEN(VAR, EXPR) \
+ if (const auto VAR = (EXPR); !(VAR)) { \
+ BOOST_REQUIRE(VAR); \
+ } \
+ else
+#define BOOST_CHECK_IF(VAR, EXPR) \
+ if (const auto VAR = (EXPR); !(VAR)) { \
+ BOOST_CHECK(VAR); \
+ } \
+ else