|
| 1 | +// Boost.Geometry (aka GGL, Generic Geometry Library) |
| 2 | +// Unit Test |
| 3 | + |
| 4 | +// Copyright (c) 2020 Tinko Bartels, Berlin, Germany. |
| 5 | + |
| 6 | +// Contributed and/or modified by Tinko Bartels, |
| 7 | +// as part of Google Summer of Code 2020 program. |
| 8 | + |
| 9 | +// Use, modification and distribution is subject to the Boost Software License, |
| 10 | +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
| 11 | +// http://www.boost.org/LICENSE_1_0.txt) |
| 12 | + |
| 13 | +#include <array> |
| 14 | + |
| 15 | +#include <geometry_test_common.hpp> |
| 16 | + |
| 17 | +#include <boost/geometry/extensions/generic_robust_predicates/strategies/cartesian/detail/expressions.hpp> |
| 18 | +#include <boost/geometry/extensions/generic_robust_predicates/strategies/cartesian/detail/stage_a.hpp> |
| 19 | + |
| 20 | +template <typename CalculationType> |
| 21 | +void test_all() |
| 22 | +{ |
| 23 | + using bg::detail::generic_robust_predicates::orient3d; |
| 24 | + using bg::detail::generic_robust_predicates::stage_a_semi_static; |
| 25 | + using bg::detail::generic_robust_predicates::stage_a_almost_static; |
| 26 | + using bg::detail::generic_robust_predicates::stage_a_static; |
| 27 | + using ct = CalculationType; |
| 28 | + using semi_static = stage_a_semi_static<orient3d, ct>; |
| 29 | + BOOST_CHECK_EQUAL(1, |
| 30 | + semi_static::apply(1, 0, 0, |
| 31 | + 0, 1, 0, |
| 32 | + 1, 1, 0, |
| 33 | + 0, 0, 1)); |
| 34 | + BOOST_CHECK_EQUAL(-1, |
| 35 | + semi_static::apply(1, 0, 0, |
| 36 | + 0, 1, 0, |
| 37 | + 1, 1, 0, |
| 38 | + 0, 0, -1)); |
| 39 | + BOOST_CHECK_EQUAL(0, |
| 40 | + semi_static::apply(1, 0, 0, |
| 41 | + 0, 1, 0, |
| 42 | + 1, 1, 0, |
| 43 | + 0, 0, 0)); |
| 44 | + stage_a_static<orient3d, ct> stat(10, 10, 10, |
| 45 | + 10, 10, 10, |
| 46 | + 10, 10, 10, |
| 47 | + 10, 10, 10, |
| 48 | + 0, 0, 0, |
| 49 | + 0, 0, 0, |
| 50 | + 0, 0, 0, |
| 51 | + 0, 0, 0); |
| 52 | + BOOST_CHECK_EQUAL(1, stat.apply(1, 0, 0, |
| 53 | + 0, 1, 0, |
| 54 | + 1, 1, 0, |
| 55 | + 0, 0, 1)); |
| 56 | + |
| 57 | + stage_a_static<orient3d, ct> pessimistic(1e40, 1e40, 1e40, |
| 58 | + 1e40, 1e40, 1e40, |
| 59 | + 1e40, 1e40, 1e40, |
| 60 | + 1e40, 1e40, 1e40, |
| 61 | + 0, 0, 0, |
| 62 | + 0, 0, 0, |
| 63 | + 0, 0, 0, |
| 64 | + 0, 0, 0); |
| 65 | + BOOST_CHECK_EQUAL(bg::detail::generic_robust_predicates::sign_uncertain, |
| 66 | + pessimistic.apply(1, 0, 0, |
| 67 | + 0, 1, 0, |
| 68 | + 1, 1, 0, |
| 69 | + 0, 0, 1)); |
| 70 | +} |
| 71 | + |
| 72 | +int test_main(int, char* []) |
| 73 | +{ |
| 74 | + test_all<double>(); |
| 75 | + return 0; |
| 76 | +} |
0 commit comments