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_EXPAND_HPP
10 #define BOOST_GEOMETRY_TEST_EXPAND_HPP
11 
12 
13 #include <geometry_test_common.hpp>
14 
15 #include <boost/geometry/algorithms/expand.hpp>
16 #include <boost/geometry/strategies/strategies.hpp>
17 #include <boost/geometry/io/wkt/read.hpp>
18 #include <boost/geometry/algorithms/assign.hpp>
19 #include <boost/geometry/io/dsv/write.hpp>
20 #include <boost/variant/variant.hpp>
21 
22 
23 template <typename Box>
to_dsv(const Box & box)24 inline std::string to_dsv(const Box& box)
25 {
26     std::ostringstream out;
27     out << bg::dsv(box, ",", "(", ")", ",", "", "");
28     return out.str();
29 }
30 
31 
32 template <typename Geometry, typename Box>
test_expand(Box & box,std::string const & wkt,std::string const & expected)33 void test_expand(Box& box,
34                   std::string const& wkt,
35                   std::string const& expected)
36 {
37     Geometry geometry;
38     bg::read_wkt(wkt, geometry);
39 
40     bg::expand(box, geometry);
41 
42     BOOST_CHECK_EQUAL(to_dsv(box), expected);
43 
44 #if !defined(BOOST_GEOMETRY_TEST_DEBUG)
45     bg::expand(box, boost::variant<Geometry>(geometry));
46 
47     BOOST_CHECK_EQUAL(to_dsv(box), expected);
48 #endif
49 }
50 
51 template <typename Geometry, typename Box>
test_expand_other_strategy(Box & box,std::string const & wkt,std::string const & expected)52 void test_expand_other_strategy(Box& box,
53                   std::string const& wkt,
54                   std::string const& expected)
55 {
56     Geometry geometry;
57     bg::read_wkt(wkt, geometry);
58 
59     bg::expand(box, geometry);
60 
61     BOOST_CHECK_EQUAL(to_dsv(box), expected);
62 
63 #if !defined(BOOST_GEOMETRY_TEST_DEBUG)
64     bg::expand(box, boost::variant<Geometry>(geometry));
65 
66     BOOST_CHECK_EQUAL(to_dsv(box), expected);
67 #endif
68 }
69 
70 
71 #endif
72