diff options
Diffstat (limited to 'test/test-maths.cpp')
-rw-r--r-- | test/test-maths.cpp | 18 |
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); +} |