Imported Upstream version 1.49.0
[platform/upstream/boost.git] / libs / geometry / test / algorithms / test_intersects.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library) 
2 // Unit Test
3
4 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Use, modification and distribution is subject to the Boost Software License,
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8
9 #ifndef BOOST_GEOMETRY_TEST_INTERSECTS_HPP
10 #define BOOST_GEOMETRY_TEST_INTERSECTS_HPP
11
12
13 #include <geometry_test_common.hpp>
14
15 #include <boost/geometry/core/ring_type.hpp>
16 #include <boost/geometry/algorithms/intersects.hpp>
17 #include <boost/geometry/strategies/strategies.hpp>
18 #include <boost/geometry/geometries/ring.hpp>
19 #include <boost/geometry/geometries/polygon.hpp>
20
21 #include <boost/geometry/io/wkt/read.hpp>
22
23
24 template <typename Geometry1, typename Geometry2>
25 void test_geometry(std::string const& wkt1,
26         std::string const& wkt2, bool expected)
27 {
28     Geometry1 geometry1;
29     Geometry2 geometry2;
30
31     bg::read_wkt(wkt1, geometry1);
32     bg::read_wkt(wkt2, geometry2);
33
34     bool detected = bg::intersects(geometry1, geometry2);
35
36     BOOST_CHECK_MESSAGE(detected == expected,
37         "intersects: " << wkt1
38         << " with " << wkt2
39         << " -> Expected: " << expected
40         << " detected: " << detected);
41 }
42
43
44 template <typename Geometry>
45 void test_self_intersects(std::string const& wkt, bool expected)
46 {
47     Geometry geometry;
48
49     bg::read_wkt(wkt, geometry);
50
51     bool detected = bg::intersects(geometry);
52
53     BOOST_CHECK_MESSAGE(detected == expected,
54         "intersects: " << wkt
55         << " -> Expected: " << expected
56         << " detected: " << detected);
57 }
58
59
60
61 #endif