1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
5
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9
10 #include <deque>
11 #include <vector>
12
13 #include <geometry_test_common.hpp>
14 #include <boost/core/ignore_unused.hpp>
15
16 #include <boost/geometry/geometries/geometries.hpp>
17
18 #include <boost/geometry/geometries/adapted/c_array.hpp>
19 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
20
21 #include <test_common/test_point.hpp>
22
23 #define BOOST_GEOMETRY_TEST_RING
24
25
26
27 #if defined(BOOST_GEOMETRY_TEST_RING)
28
29 #include <boost/geometry/geometries/register/ring.hpp>
30 #include <boost/geometry/geometries/concepts/ring_concept.hpp>
31
32 BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(std::vector)
BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(std::deque)33 BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(std::deque)
34
35 #elif defined(BOOST_GEOMETRY_TEST_MULTI_POINT)
36
37 #include <boost/geometry/geometries/register/multi_point.hpp>
38 #include <boost/geometry/geometries/concepts/multi_point_concept.hpp>
39
40 BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(std::vector)
41 BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(std::deque)
42
43 #else
44
45 #include <boost/geometry/geometries/register/linestring.hpp>
46 #include <boost/geometry/geometries/concepts/linestring_concept.hpp>
47
48 BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector)
49 BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque)
50
51 #endif
52
53
54 BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
55 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
56
57
58 // ----------------------------------------------------------------------------
59
60 template <typename G>
61 void test_geometry(G const& geometry, std::size_t expected_size = 0)
62 {
63 #if defined(BOOST_GEOMETRY_TEST_RING)
64 BOOST_CONCEPT_ASSERT( (bg::concepts::ConstRing<G>) );
65 #elif defined(BOOST_GEOMETRY_TEST_MULTI_POINT)
66 BOOST_CONCEPT_ASSERT( (bg::concepts::ConstMultiPoint<G>) );
67 #else
68 BOOST_CONCEPT_ASSERT( (bg::concepts::ConstLinestring<G>) );
69 #endif
70
71 typedef typename bg::point_type<G>::type P;
72 typedef typename bg::coordinate_type<P>::type C;
73 boost::ignore_unused<P, C>();
74
75 // Check range-like behaviour
76 BOOST_CHECK_EQUAL(boost::size(geometry), expected_size);
77 }
78
79 template <typename P>
test_all()80 void test_all()
81 {
82 test_geometry(std::vector<P>());
83 test_geometry(std::deque<P>());
84 //test_geometry(std::list<P>());
85
86 /***
87 double vertices[][3] = {
88 {-1, -1, 1}, {1, -1, 1}, {1, 1, 1}, {-1, 1, 1},
89 {-1, -1, -1}, {1, -1, -1}, {1, 1, -1}, {-1, 1, -1}
90 };
91
92 test_geometry(vertices, 8);
93 ***/
94 }
95
test_main(int,char * [])96 int test_main(int, char* [])
97 {
98 test_all<test::test_point>();
99 test_all<boost::tuple<float, float> >();
100 test_all<bg::model::point<int, 2, bg::cs::cartesian> >();
101 test_all<bg::model::point<float, 2, bg::cs::cartesian> >();
102 test_all<bg::model::point<double, 2, bg::cs::cartesian> >();
103 test_all<bg::model::point<long double, 2, bg::cs::cartesian> >();
104
105 test_all<boost::tuple<float, float, float> >();
106 test_all<bg::model::point<double, 3, bg::cs::cartesian> >();
107 test_all<bg::model::point<long double, 3, bg::cs::cartesian> >();
108
109 test_all<boost::tuple<float, float, float, float, float> >();
110
111 return 0;
112 }
113