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) 2008-2012 Bruno Lalande, Paris, France.
6 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
7
8 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
9 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
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_CORRECT_HPP
16 #define BOOST_GEOMETRY_TEST_CORRECT_HPP
17
18
19 // Test-functionality, shared between single and multi tests
20
21 #include <sstream>
22
23 #include <geometry_test_common.hpp>
24
25 #include <boost/geometry/algorithms/correct.hpp>
26 #include <boost/geometry/io/wkt/read.hpp>
27 #include <boost/geometry/io/wkt/write.hpp>
28 #include <boost/variant/variant.hpp>
29
30 template <typename Geometry>
check_geometry(Geometry const & geometry,std::string const & expected)31 void check_geometry(Geometry const& geometry, std::string const& expected)
32 {
33 std::ostringstream out;
34 out << bg::wkt_manipulator<Geometry>(geometry, false);
35
36 BOOST_CHECK_EQUAL(out.str(), expected);
37 }
38
39 template <typename Geometry>
test_geometry(std::string const & wkt,std::string const & expected)40 void test_geometry(std::string const& wkt, std::string const& expected)
41 {
42 Geometry geometry;
43 bg::read_wkt(wkt, geometry);
44 boost::variant<Geometry> v(geometry);
45
46 bg::correct(geometry);
47 check_geometry(geometry, expected);
48
49 bg::correct(v);
50 check_geometry(v, expected);
51 }
52
53
54 #endif
55