PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://hadesmem.googlecode.com/
C++ | 75 lines | 48 code | 16 blank | 11 comment | 0 complexity | 3e073917a3fed5d1ac33b94aebc58a63 MD5 | raw file
 1// Boost.Geometry (aka GGL, Generic Geometry Library)
 2// Unit Test
 3
 4// Copyright (c) 2010 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_reverse.hpp>
12#include <boost/geometry/geometries/geometries.hpp>
13#include <boost/geometry/geometries/point_xy.hpp>
14
15#include <test_common/test_point.hpp>
16#include <test_geometries/all_custom_linestring.hpp>
17#include <test_geometries/all_custom_ring.hpp>
18#include <test_geometries/wrapped_boost_array.hpp>
19
20template <typename LineString>
21void test_linestring()
22{
23    // Simplex
24    test_geometry<LineString >(
25        "LINESTRING(0 0,1 1)",
26        "LINESTRING(1 1,0 0)");
27
28    // Three points, middle should stay the same
29    test_geometry<LineString >(
30        "LINESTRING(0 0,1 1,2 2)",
31        "LINESTRING(2 2,1 1,0 0)");
32
33    // Four points
34    test_geometry<LineString >(
35        "LINESTRING(0 0,1 1,2 2,3 3)",
36        "LINESTRING(3 3,2 2,1 1,0 0)");
37}
38
39template <typename Ring>
40void test_ring()
41{
42    test_geometry<Ring>(
43        "POLYGON((4 0,8 2,8 7,4 9,0 7,0 2,2 1,4 0))",
44        "POLYGON((4 0,2 1,0 2,0 7,4 9,8 7,8 2,4 0))");
45}
46
47template <typename Point>
48void test_all()
49{
50    test_linestring<bg::model::linestring<Point> >();
51    test_linestring<all_custom_linestring<Point> >();
52
53    // Polygon with holes
54    test_geometry<bg::model::polygon<Point> >(
55        "POLYGON((4 0,8 2,8 7,4 9,0 7,0 2,2 1,4 0),(7 3,7 6,1 6,1 3,4 3,7 3))",
56        "POLYGON((4 0,2 1,0 2,0 7,4 9,8 7,8 2,4 0),(7 3,4 3,1 3,1 6,7 6,7 3))");
57
58    // Check compilation
59    test_geometry<Point>("POINT(0 0)", "POINT(0 0)");
60
61    test_ring<bg::model::ring<Point> >();
62    test_ring<all_custom_ring<Point> >();
63}
64
65int test_main(int, char* [])
66{
67    test_all<bg::model::d2::point_xy<int> >();
68    test_all<bg::model::d2::point_xy<double> >();
69
70#if defined(HAVE_TTMATH)
71    test_all<bg::model::d2::point_xy<ttmath_big> >();
72#endif
73
74    return 0;
75}