1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2011-2012 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
15 #include <boost/geometry/algorithms/append.hpp>
16 #include <boost/geometry/algorithms/clear.hpp>
17 #include <boost/geometry/algorithms/make.hpp>
18 #include <boost/geometry/core/access.hpp>
19 #include <boost/geometry/geometries/geometries.hpp>
20 #include <boost/geometry/geometries/concepts/linestring_concept.hpp>
21
22 #include <boost/geometry/io/dsv/write.hpp>
23
24
25 #include <test_common/test_point.hpp>
26 #include <test_geometries/all_custom_linestring.hpp>
27 #include <test_geometries/wrapped_boost_array.hpp>
28
29
30
31 template <typename Geometry>
test_linestring()32 void test_linestring()
33 {
34 BOOST_CONCEPT_ASSERT( (bg::concepts::Linestring<Geometry>) );
35 BOOST_CONCEPT_ASSERT( (bg::concepts::ConstLinestring<Geometry>) );
36
37 Geometry geometry;
38 typedef typename bg::point_type<Geometry>::type P;
39
40 bg::clear(geometry);
41 BOOST_CHECK_EQUAL(boost::size(geometry), 0u);
42
43 bg::append(geometry, bg::make<P>(1, 2));
44 BOOST_CHECK_EQUAL(boost::size(geometry), 1u);
45
46 bg::append(geometry, bg::make<P>(3, 4));
47 BOOST_CHECK_EQUAL(boost::size(geometry), 2u);
48
49 bg::traits::resize<Geometry>::apply(geometry, 1);
50 BOOST_CHECK_EQUAL(boost::size(geometry), 1u);
51
52 //std::cout << bg::dsv(geometry) << std::endl;
53 P p = *boost::begin(geometry);
54 //std::cout << bg::dsv(p) << std::endl;
55 BOOST_CHECK_EQUAL(bg::get<0>(p), 1);
56 BOOST_CHECK_EQUAL(bg::get<1>(p), 2);
57
58 bg::clear(geometry);
59 BOOST_CHECK_EQUAL(boost::size(geometry), 0u);
60 }
61
62 template <typename Point>
test_all()63 void test_all()
64 {
65 test_linestring<bg::model::linestring<Point> >();
66 test_linestring<test::wrapped_boost_array<Point, 10> >();
67 test_linestring<all_custom_linestring<Point> >();
68 }
69
test_main(int,char * [])70 int test_main(int, char* [])
71 {
72 test_all<bg::model::point<int, 2, bg::cs::cartesian> >();
73 test_all<bg::model::point<float, 2, bg::cs::cartesian> >();
74 test_all<bg::model::point<double, 2, bg::cs::cartesian> >();
75
76 return 0;
77 }
78