summaryrefslogtreecommitdiff
path: root/test/test-maths.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-02-22 20:12:59 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-02-22 20:12:59 +0000
commit838e5f77478e5648769439e191e3ff0a8e6405ab (patch)
treee42961851585d6cc519247671bb3bad8ca9453a3 /test/test-maths.cpp
parentArc stream operator is inline, say so (diff)
downloadilt-838e5f77478e5648769439e191e3ff0a8e6405ab.tar.bz2
ilt-838e5f77478e5648769439e191e3ff0a8e6405ab.tar.xz
ilt-838e5f77478e5648769439e191e3ff0a8e6405ab.zip
Add meandering support
Add rail links between existing nodes and arbitrary points
Diffstat (limited to 'test/test-maths.cpp')
-rw-r--r--test/test-maths.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/test-maths.cpp b/test/test-maths.cpp
index 49114da..d5848c6 100644
--- a/test/test-maths.cpp
+++ b/test/test-maths.cpp
@@ -2,6 +2,7 @@
#include <boost/test/data/test_case.hpp>
#include <boost/test/unit_test.hpp>
+#include <iomanip>
#include <stream_support.hpp>
#include <glm/glm.hpp>
@@ -74,3 +75,20 @@ BOOST_DATA_TEST_CASE(test_create_arc,
BOOST_CHECK_CLOSE(arc.first, a.first, 1.F);
BOOST_CHECK_CLOSE(arc.second, a.second, 1.F);
}
+
+using fac = std::tuple<glm::vec2, float, glm::vec2, float, glm::vec2, bool>;
+BOOST_DATA_TEST_CASE(test_find_arc_centre,
+ boost::unit_test::data::make<fac>({
+ {{2, 2}, pi, {3, 3}, half_pi, {3, 2}, true},
+ {{2, 2}, pi, {1, 3}, -half_pi, {1, 2}, false},
+ {{-1100, -1000}, pi, {-900, -800}, half_pi, {-900, -1000}, true},
+ {{1100, 1000}, 0, {1050, 900}, pi + 0.92, {973, 1000}, true},
+ {{1050, 900}, 0.92, {1000, 800}, pi, {1127, 800}, false},
+ }),
+ s, es, e, ee, exp, lr)
+{
+ const auto c = find_arc_centre(s, es, e, ee);
+ BOOST_CHECK_CLOSE(exp.x, c.first.x, 1);
+ BOOST_CHECK_CLOSE(exp.y, c.first.y, 1);
+ BOOST_CHECK_EQUAL(lr, c.second);
+}