PageRenderTime 11ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/Src/Dependencies/Boost/libs/geometry/test/algorithms/for_each.cpp

http://hadesmem.googlecode.com/
C++ | 81 lines | 55 code | 18 blank | 8 comment | 0 complexity | 74d49c09b941964971d4eb2bf9d40e80 MD5 | raw file
 1// Boost.Geometry (aka GGL, Generic Geometry Library)
 2// Unit Test
 3
 4// Copyright (c) 2007-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
11#include <algorithms/test_for_each.hpp>
12
13#include <boost/geometry/geometries/geometries.hpp>
14
15
16
17template <typename P>
18void test_all()
19{
20    test_geometry<P>
21        (
22            "POINT(1 1)"
23
24            // per point
25            , 1
26            , "POINT(101 1)"
27            , "POINT(101 100)"
28            // per segment
29            , ""
30            , 0
31            , "POINT(1 1)"
32        );
33    test_geometry<bg::model::linestring<P> >
34        (
35            "LINESTRING(1 1,2 2)"
36
37            , 3
38            , "LINESTRING(101 1,102 2)"
39            , "LINESTRING(101 100,102 200)"
40
41            , "((1, 1), (2, 2))"
42            , std::sqrt(2.0)
43            , "LINESTRING(10 1,2 2)"
44        );
45    test_geometry<bg::model::ring<P> >
46        (
47            "POLYGON((1 1,1 4,4 4,4 1,1 1))"
48
49            , 11
50            , "POLYGON((101 1,101 4,104 4,104 1,101 1))"
51            , "POLYGON((101 100,101 400,104 400,104 100,101 100))"
52
53            , "((1, 1), (1, 4)) ((1, 4), (4, 4)) ((4, 4), (4, 1)) ((4, 1), (1, 1))"
54            , 4 * 3.0
55            , "POLYGON((10 1,10 4,4 4,4 1,1 1))"
56        );
57    test_geometry<bg::model::polygon<P> >
58        (
59            "POLYGON((1 1,1 4,4 4,4 1,1 1),(2 2,3 2,3 3,2 3,2 2))"
60
61            , 23
62            , "POLYGON((101 1,101 4,104 4,104 1,101 1),(102 2,103 2,103 3,102 3,102 2))"
63            , "POLYGON((101 100,101 400,104 400,104 100,101 100),(102 200,103 200,103 300,102 300,102 200))"
64
65            , "((1, 1), (1, 4)) ((1, 4), (4, 4)) ((4, 4), (4, 1)) ((4, 1), (1, 1)) "
66              "((2, 2), (3, 2)) ((3, 2), (3, 3)) ((3, 3), (2, 3)) ((2, 3), (2, 2))"
67            , 4 * 3.0 + 4 * 1.0
68            , "POLYGON((10 1,10 4,4 4,4 1,1 1),(2 2,3 2,3 3,2 3,2 2))"
69        );
70}
71
72int test_main(int, char* [])
73{
74    test_all<bg::model::point<double, 2, bg::cs::cartesian> >();
75
76#if defined(HAVE_TTMATH)
77    test_all<bg::model::point<ttmath_big, 2, bg::cs::cartesian> >();
78#endif
79
80    return 0;
81}