PageRenderTime 22ms CodeModel.GetById 17ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/geometry/test/util/write_dsv.cpp

http://hadesmem.googlecode.com/
C++ | 73 lines | 38 code | 25 blank | 10 comment | 0 complexity | 6174dd3dbbc6174a51a28ad5067bc0f3 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// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
 6// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
 7
 8// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
 9// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
10
11// Use, modification and distribution is subject to the Boost Software License,
12// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13// http://www.boost.org/LICENSE_1_0.txt)
14
15
16#include <sstream>
17
18#include <geometry_test_common.hpp>
19
20#include <boost/geometry/util/write_dsv.hpp>
21
22
23#include <boost/geometry/geometries/geometries.hpp>
24
25#include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
26
27
28
29template <typename G>
30void test_dsv(std::string const& wkt, std::string const& dsv)
31{
32    G geometry;
33
34    bg::read_wkt(wkt, geometry);
35
36    std::ostringstream out;
37    out << bg::dsv(geometry);
38    BOOST_CHECK_EQUAL(out.str(), dsv);
39}
40
41
42#ifndef GEOMETRY_TEST_MULTI
43template <typename T>
44void test_all()
45{
46    using namespace boost::geometry;
47    typedef model::point<T, 2, cs::cartesian> P;
48
49    test_dsv<P >("POINT(1 2)", "(1, 2)");
50    test_dsv<model::linestring<P> >(
51        "LINESTRING(1 1,2 2,3 3)",
52        "((1, 1), (2, 2), (3, 3))");
53    test_dsv<model::polygon<P> >("POLYGON((0 0,0 4,4 4,4 0,0 0))",
54        "(((0, 0), (0, 4), (4, 4), (4, 0), (0, 0)))");
55
56    test_dsv<model::ring<P> >("POLYGON((0 0,0 4,4 4,4 0,0 0))",
57        "((0, 0), (0, 4), (4, 4), (4, 0), (0, 0))");
58
59    test_dsv<model::box<P> >("BOX(0 0,1 1)",
60        "((0, 0), (1, 1))");
61}
62#endif
63
64
65int test_main(int, char* [])
66{
67    test_all<double>();
68    test_all<int>();
69
70
71    return 0;
72}
73