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