PageRenderTime 50ms CodeModel.GetById 37ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/geometry/test/concepts/linestring_concept.cpp

http://hadesmem.googlecode.com/
C++ | 77 lines | 48 code | 21 blank | 8 comment | 0 complexity | e5e368442b8483bc5b9c6a4ed4bed664 MD5 | raw file
 1// Boost.Geometry (aka GGL, Generic Geometry Library)
 2// Unit Test
 3
 4// Copyright (c) 2011 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/util/write_dsv.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
31template <typename Geometry>
32void test_linestring()
33{
34    BOOST_CONCEPT_ASSERT( (bg::concept::Linestring<Geometry>) );
35    BOOST_CONCEPT_ASSERT( (bg::concept::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), 0);
42
43    bg::append(geometry, bg::make<P>(1, 2));
44    BOOST_CHECK_EQUAL(boost::size(geometry), 1);
45
46    bg::append(geometry, bg::make<P>(3, 4));
47    BOOST_CHECK_EQUAL(boost::size(geometry), 2);
48
49    bg::traits::resize<Geometry>::apply(geometry, 1);
50    BOOST_CHECK_EQUAL(boost::size(geometry), 1);
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), 0);
60}
61
62template <typename Point>
63void 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
70int 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}