Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / geometry / test / algorithms / buffer / buffer.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2007-2019 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
6 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
7
8 // This file was modified by Oracle on 2016.
9 // Modifications copyright (c) 2016, Oracle and/or its affiliates.
10 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
14
15 // Use, modification and distribution is subject to the Boost Software License,
16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
18
19
20 #include <boost/variant/variant.hpp>
21
22 #include "geometry_test_common.hpp"
23
24 #include <boost/geometry/algorithms/buffer.hpp>
25 #include <boost/geometry/algorithms/equals.hpp>
26 #include <boost/geometry/core/coordinate_type.hpp>
27
28 #include <boost/geometry/strategies/strategies.hpp>
29
30 #include <boost/geometry/geometries/point.hpp>
31 #include <boost/geometry/geometries/box.hpp>
32 #include "test_common/test_point.hpp"
33
34
35 template <typename P>
36 void test_all()
37 {
38     typedef typename bg::coordinate_type<P>::type coordinate_type;
39
40     P p1(0, 0);
41     P p2(2, 2);
42
43     typedef bg::model::box<P> box_type;
44
45     box_type b1(p1, p2);
46     box_type b2;
47     bg::buffer(b1, b2, coordinate_type(2));
48
49     box_type expected(P(-2, -2), P(4, 4));
50     BOOST_CHECK(bg::equals(b2, expected));
51
52     boost::variant<box_type> v(b1);
53     bg::buffer(v, b2, coordinate_type(2));
54
55     BOOST_CHECK(bg::equals(b2, expected));
56 }
57
58 int test_main(int, char* [])
59 {
60     BoostGeometryWriteTestConfiguration();
61
62     test_all<bg::model::point<default_test_type, 2, bg::cs::cartesian> >();
63
64 #if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
65     test_all<bg::model::point<int, 2, bg::cs::cartesian> >();
66     test_all<bg::model::point<float, 2, bg::cs::cartesian> >();
67 #endif
68
69 #ifdef HAVE_TTMATH
70     test_all<bg::model::point<ttmath_big, 2, bg::cs::cartesian> >();
71 #endif
72     return 0;
73 }