]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/relational_operations/equals/test_equals.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / relational_operations / equals / test_equals.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2014-2017 Adam Wulkiewicz, Lodz, Poland.
6
7 // This file was modified by Oracle on 2016-2017.
8 // Modifications copyright (c) 2016-2017 Oracle and/or its affiliates.
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
14
15 #ifndef BOOST_GEOMETRY_TEST_EQUALS_HPP
16 #define BOOST_GEOMETRY_TEST_EQUALS_HPP
17
18
19 #include <geometry_test_common.hpp>
20
21 #include <boost/geometry/core/ring_type.hpp>
22 #include <boost/geometry/algorithms/correct.hpp>
23 #include <boost/geometry/algorithms/equals.hpp>
24 #include <boost/geometry/strategies/strategies.hpp>
25 #include <boost/geometry/io/wkt/read.hpp>
26 #include <boost/variant/variant.hpp>
27
28
29 struct no_strategy {};
30
31 template <typename Geometry1, typename Geometry2, typename Strategy>
32 bool call_equals(Geometry1 const& geometry1,
33 Geometry2 const& geometry2,
34 Strategy const& strategy)
35 {
36 return bg::equals(geometry1, geometry2, strategy);
37 }
38
39 template <typename Geometry1, typename Geometry2>
40 bool call_equals(Geometry1 const& geometry1,
41 Geometry2 const& geometry2,
42 no_strategy)
43 {
44 return bg::equals(geometry1, geometry2);
45 }
46
47 template <typename Geometry1, typename Geometry2, typename Strategy>
48 void check_geometry(Geometry1 const& geometry1,
49 Geometry2 const& geometry2,
50 std::string const& caseid,
51 std::string const& wkt1,
52 std::string const& wkt2,
53 bool expected,
54 Strategy const& strategy)
55 {
56 bool detected = call_equals(geometry1, geometry2, strategy);
57
58 BOOST_CHECK_MESSAGE(detected == expected,
59 "case: " << caseid
60 << " equals: " << wkt1
61 << " to " << wkt2
62 << " -> Expected: " << expected
63 << " detected: " << detected);
64
65 detected = call_equals(geometry2, geometry1, strategy);
66
67 BOOST_CHECK_MESSAGE(detected == expected,
68 "case: " << caseid
69 << " equals: " << wkt2
70 << " to " << wkt1
71 << " -> Expected: " << expected
72 << " detected: " << detected);
73 }
74
75
76 template <typename Geometry1, typename Geometry2>
77 void test_geometry(std::string const& caseid,
78 std::string const& wkt1,
79 std::string const& wkt2,
80 bool expected,
81 bool correct_geometries = false)
82 {
83 Geometry1 geometry1;
84 Geometry2 geometry2;
85
86 bg::read_wkt(wkt1, geometry1);
87 bg::read_wkt(wkt2, geometry2);
88
89 if (correct_geometries)
90 {
91 bg::correct(geometry1);
92 bg::correct(geometry2);
93 }
94
95 typedef typename bg::strategy::relate::services::default_strategy
96 <
97 Geometry1, Geometry2
98 >::type strategy_type;
99
100 check_geometry(geometry1, geometry2, caseid, wkt1, wkt2, expected, no_strategy());
101 check_geometry(geometry1, geometry2, caseid, wkt1, wkt2, expected, strategy_type());
102 check_geometry(boost::variant<Geometry1>(geometry1), geometry2, caseid, wkt1, wkt2, expected, no_strategy());
103 check_geometry(geometry1, boost::variant<Geometry2>(geometry2), caseid, wkt1, wkt2, expected, no_strategy());
104 check_geometry(boost::variant<Geometry1>(geometry1), boost::variant<Geometry2>(geometry2), caseid, wkt1, wkt2, expected, no_strategy());
105 }
106
107 template <typename Geometry1, typename Geometry2>
108 void test_geometry(std::string const& wkt1,
109 std::string const& wkt2,
110 bool expected)
111 {
112 test_geometry<Geometry1, Geometry2>("", wkt1, wkt2, expected);
113 }
114
115 #endif