1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | |
3 | // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. |
4 | // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. |
5 | // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. |
6 | |
7 | // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library |
8 | // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. |
9 | |
10 | // Use, modification and distribution is subject to the Boost Software License, |
11 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
12 | // http://www.boost.org/LICENSE_1_0.txt) |
13 | |
14 | |
15 | #ifndef GEOMETRY_TEST_GEOMETRY_TEST_COMMON_HPP |
16 | #define GEOMETRY_TEST_GEOMETRY_TEST_COMMON_HPP |
17 | |
18 | #include <boost/config.hpp> |
19 | |
20 | // Determine debug/release mode |
21 | // (it would be convenient if Boost.Config or Boost.Test would define this) |
22 | // Note that they might be combined (e.g. for optimize+no inline) |
23 | #if defined (BOOST_CLANG) || defined(BOOST_GCC) |
24 | #if defined(__OPTIMIZE__) |
25 | #define BOOST_GEOMETRY_COMPILER_MODE_RELEASE |
26 | #endif |
27 | #if defined(__NO_INLINE__) |
28 | #define BOOST_GEOMETRY_COMPILER_MODE_DEBUG |
29 | #endif |
30 | #endif |
31 | |
32 | #if defined(BOOST_MSVC) |
33 | #if defined(_DEBUG) |
34 | #define BOOST_GEOMETRY_COMPILER_MODE_DEBUG |
35 | #else |
36 | #define BOOST_GEOMETRY_COMPILER_MODE_RELEASE |
37 | #endif |
38 | #endif |
39 | |
40 | |
41 | #if defined(BOOST_MSVC) |
42 | // We deliberately mix float/double's so turn off warnings |
43 | #pragma warning( disable : 4244 ) |
44 | // For (new since Boost 1.40) warning in Boost.Test on putenv/posix |
45 | #pragma warning( disable : 4996 ) |
46 | |
47 | //#pragma warning( disable : 4305 ) |
48 | #endif // defined(BOOST_MSVC) |
49 | |
50 | #include <boost/config.hpp> |
51 | #include <boost/concept_check.hpp> |
52 | |
53 | |
54 | #if defined(BOOST_INTEL_CXX_VERSION) |
55 | #define BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE |
56 | #endif |
57 | |
58 | |
59 | #include <boost/foreach.hpp> |
60 | |
61 | #include <string_from_type.hpp> |
62 | |
63 | // Include some always-included-for-testing files |
64 | #if ! defined(BOOST_GEOMETRY_NO_BOOST_TEST) |
65 | |
66 | // Until Boost.Test fixes it, silence warning issued by clang: |
67 | #ifdef __clang__ |
68 | # pragma clang diagnostic push |
69 | // warning: unused variable 'check_is_close' [-Wunused-variable] |
70 | # pragma clang diagnostic ignored "-Wunused-variable" |
71 | // warnings when -Wconversion is set |
72 | # pragma clang diagnostic ignored "-Wsign-conversion" |
73 | # pragma clang diagnostic ignored "-Wshorten-64-to-32" |
74 | #endif |
75 | |
76 | # include <boost/test/floating_point_comparison.hpp> |
77 | #ifndef BOOST_TEST_MODULE |
78 | # include <boost/test/included/test_exec_monitor.hpp> |
79 | //# include <boost/test/included/prg_exec_monitor.hpp> |
80 | # include <boost/test/impl/execution_monitor.ipp> |
81 | #endif |
82 | |
83 | #ifdef __clang__ |
84 | # pragma clang diagnostic pop |
85 | #endif |
86 | |
87 | #endif |
88 | |
89 | |
90 | #if defined(HAVE_TTMATH) |
91 | # include <boost/geometry/extensions/contrib/ttmath_stub.hpp> |
92 | #endif |
93 | |
94 | #if defined(HAVE_CLN) || defined(HAVE_GMP) |
95 | # include <boost/numeric_adaptor/numeric_adaptor.hpp> |
96 | #endif |
97 | |
98 | |
99 | #if defined(HAVE_GMP) |
100 | # include <boost/numeric_adaptor/gmp_value_type.hpp> |
101 | #endif |
102 | #if defined(HAVE_CLN) |
103 | # include <boost/numeric_adaptor/cln_value_type.hpp> |
104 | #endif |
105 | |
106 | // For all tests: |
107 | // - do NOT use "using namespace boost::geometry" to make clear what is Boost.Geometry |
108 | // - use bg:: as short alias |
109 | #include <boost/geometry/core/coordinate_type.hpp> |
110 | #include <boost/geometry/core/closure.hpp> |
111 | #include <boost/geometry/core/point_order.hpp> |
112 | #include <boost/geometry/core/tag.hpp> |
113 | namespace bg = boost::geometry; |
114 | |
115 | |
116 | template <typename CoordinateType, typename T1, typename T2> |
117 | inline T1 if_typed_tt(T1 value_tt, T2 value) |
118 | { |
119 | #if defined(HAVE_TTMATH) |
120 | return boost::is_same<CoordinateType, ttmath_big>::type::value ? value_tt : value; |
121 | #else |
122 | boost::ignore_unused_variable_warning(value_tt); |
123 | return value; |
124 | #endif |
125 | } |
126 | |
127 | template <typename CoordinateType, typename Specified, typename T> |
128 | inline T if_typed(T value_typed, T value) |
129 | { |
130 | return boost::is_same<CoordinateType, Specified>::value ? value_typed : value; |
131 | } |
132 | |
133 | template <typename Geometry1, typename Geometry2> |
134 | inline std::string type_for_assert_message() |
135 | { |
136 | bool const ccw = |
137 | bg::point_order<Geometry1>::value == bg::counterclockwise |
138 | || bg::point_order<Geometry2>::value == bg::counterclockwise; |
139 | bool const open = |
140 | bg::closure<Geometry1>::value == bg::open |
141 | || bg::closure<Geometry2>::value == bg::open; |
142 | |
143 | std::ostringstream out; |
144 | out << string_from_type<typename bg::coordinate_type<Geometry1>::type>::name() |
145 | << (ccw ? " ccw" : "" ) |
146 | << (open ? " open" : "" ); |
147 | return out.str(); |
148 | } |
149 | |
150 | struct geographic_policy |
151 | { |
152 | template <typename CoordinateType> |
153 | static inline CoordinateType apply(CoordinateType const& value) |
154 | { |
155 | return value; |
156 | } |
157 | }; |
158 | |
159 | struct mathematical_policy |
160 | { |
161 | template <typename CoordinateType> |
162 | static inline CoordinateType apply(CoordinateType const& value) |
163 | { |
164 | return 90 - value; |
165 | } |
166 | |
167 | }; |
168 | |
169 | |
170 | |
171 | #endif // GEOMETRY_TEST_GEOMETRY_TEST_COMMON_HPP |
172 | |