1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
6 // Copyright (c) 2016 Oracle and/or its affiliates.
7 // Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
9 // Use, modification and distribution is subject to the Boost Software License,
10 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
13 #ifndef BOOST_GEOMETRY_TEST_LENGTH_HPP
14 #define BOOST_GEOMETRY_TEST_LENGTH_HPP
16 #include <geometry_test_common.hpp>
18 #include <boost/geometry/algorithms/length.hpp>
19 #include <boost/geometry/io/wkt/wkt.hpp>
20 #include <boost/geometry/strategies/strategies.hpp>
21 #include <boost/variant/variant.hpp>
23 template <typename Geometry>
24 void test_length(Geometry const& geometry, long double expected_length)
26 typename bg::default_length_result<Geometry>::type
27 length = bg::length(geometry);
29 #ifdef BOOST_GEOMETRY_TEST_DEBUG
30 std::ostringstream out;
31 out << typeid(typename bg::coordinate_type<Geometry>::type).name()
33 << typeid(typename bg::default_length_result<Geometry>::type).name()
35 << "length : " << bg::length(geometry)
37 std::cout << out.str();
40 BOOST_CHECK_CLOSE(length, expected_length, 0.0001);
43 template <typename Geometry, typename Strategy>
44 void test_length(Geometry const& geometry, long double expected_length, Strategy strategy)
46 typename bg::default_length_result<Geometry>::type
47 length = bg::length(geometry, strategy);
49 #ifdef BOOST_GEOMETRY_TEST_DEBUG
50 std::ostringstream out;
51 out << typeid(typename bg::coordinate_type<Geometry>::type).name()
53 << typeid(typename bg::default_length_result<Geometry>::type).name()
55 << "length : " << bg::length(geometry, strategy)
57 std::cout << out.str();
60 BOOST_CHECK_CLOSE(length, expected_length, 0.0001);
63 template <typename Geometry>
64 void test_geometry(std::string const& wkt, double expected_length)
67 bg::read_wkt(wkt, geometry);
68 test_length(geometry, expected_length);
69 #if !defined(BOOST_GEOMETRY_TEST_DEBUG)
70 test_length(boost::variant<Geometry>(geometry), expected_length);
74 template <typename Geometry, typename Strategy>
75 void test_geometry(std::string const& wkt, double expected_length, Strategy strategy)
78 bg::read_wkt(wkt, geometry);
79 test_length(geometry, expected_length, strategy);
80 #if !defined(BOOST_GEOMETRY_TEST_DEBUG)
81 test_length(boost::variant<Geometry>(geometry), expected_length, strategy);
85 template <typename Geometry>
86 void test_empty_input(Geometry const& geometry)
92 catch(bg::empty_input_exception const& )
96 BOOST_CHECK_MESSAGE(false, "A empty_input_exception should have been thrown" );