]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/test/algorithms/equals/test_equals.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / equals / test_equals.hpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2// Unit Test
3
4// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
b32b8144 5// Copyright (c) 2014-2017 Adam Wulkiewicz, Lodz, Poland.
7c673cae 6
b32b8144
FG
7// This file was modified by Oracle on 2016-2017.
8// Modifications copyright (c) 2016-2017 Oracle and/or its affiliates.
7c673cae
FG
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>
b32b8144 22#include <boost/geometry/algorithms/correct.hpp>
7c673cae
FG
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
1e59de90
TL
29struct no_strategy
30{
31 using cs_tag = void;
32};
b32b8144
FG
33
34template <typename Geometry1, typename Geometry2, typename Strategy>
35bool call_equals(Geometry1 const& geometry1,
36 Geometry2 const& geometry2,
37 Strategy const& strategy)
38{
39 return bg::equals(geometry1, geometry2, strategy);
40}
41
7c673cae 42template <typename Geometry1, typename Geometry2>
b32b8144
FG
43bool call_equals(Geometry1 const& geometry1,
44 Geometry2 const& geometry2,
45 no_strategy)
46{
47 return bg::equals(geometry1, geometry2);
48}
49
50template <typename Geometry1, typename Geometry2, typename Strategy>
7c673cae
FG
51void check_geometry(Geometry1 const& geometry1,
52 Geometry2 const& geometry2,
53 std::string const& caseid,
54 std::string const& wkt1,
55 std::string const& wkt2,
b32b8144
FG
56 bool expected,
57 Strategy const& strategy)
7c673cae 58{
b32b8144 59 bool detected = call_equals(geometry1, geometry2, strategy);
7c673cae
FG
60
61 BOOST_CHECK_MESSAGE(detected == expected,
62 "case: " << caseid
63 << " equals: " << wkt1
64 << " to " << wkt2
65 << " -> Expected: " << expected
1e59de90
TL
66 << " detected: " << detected
67 << " strategy: " << typeid(Strategy).name()
68 << " cs: " << typeid(typename Strategy::cs_tag).name());
7c673cae 69
b32b8144 70 detected = call_equals(geometry2, geometry1, strategy);
7c673cae
FG
71
72 BOOST_CHECK_MESSAGE(detected == expected,
73 "case: " << caseid
b32b8144
FG
74 << " equals: " << wkt2
75 << " to " << wkt1
7c673cae 76 << " -> Expected: " << expected
1e59de90
TL
77 << " strategy: " << typeid(Strategy).name()
78 << " cs: " << typeid(typename Strategy::cs_tag).name());
7c673cae
FG
79}
80
81
82template <typename Geometry1, typename Geometry2>
83void test_geometry(std::string const& caseid,
84 std::string const& wkt1,
b32b8144
FG
85 std::string const& wkt2,
86 bool expected,
87 bool correct_geometries = false)
7c673cae
FG
88{
89 Geometry1 geometry1;
90 Geometry2 geometry2;
91
92 bg::read_wkt(wkt1, geometry1);
93 bg::read_wkt(wkt2, geometry2);
94
b32b8144
FG
95 if (correct_geometries)
96 {
97 bg::correct(geometry1);
98 bg::correct(geometry2);
99 }
100
101 typedef typename bg::strategy::relate::services::default_strategy
102 <
103 Geometry1, Geometry2
104 >::type strategy_type;
105
106 check_geometry(geometry1, geometry2, caseid, wkt1, wkt2, expected, no_strategy());
107 check_geometry(geometry1, geometry2, caseid, wkt1, wkt2, expected, strategy_type());
108 check_geometry(boost::variant<Geometry1>(geometry1), geometry2, caseid, wkt1, wkt2, expected, no_strategy());
109 check_geometry(geometry1, boost::variant<Geometry2>(geometry2), caseid, wkt1, wkt2, expected, no_strategy());
110 check_geometry(boost::variant<Geometry1>(geometry1), boost::variant<Geometry2>(geometry2), caseid, wkt1, wkt2, expected, no_strategy());
7c673cae
FG
111}
112
113template <typename Geometry1, typename Geometry2>
114void test_geometry(std::string const& wkt1,
115 std::string const& wkt2,
116 bool expected)
117{
118 test_geometry<Geometry1, Geometry2>("", wkt1, wkt2, expected);
119}
120
121#endif