summaryrefslogtreecommitdiff
path: root/libs/geometry/test/util
diff options
context:
space:
mode:
Diffstat (limited to 'libs/geometry/test/util')
-rw-r--r--libs/geometry/test/util/Jamfile.v211
-rw-r--r--libs/geometry/test/util/as_range.cpp79
-rw-r--r--libs/geometry/test/util/promote_integral.cpp547
-rw-r--r--libs/geometry/test/util/range.cpp31
-rw-r--r--libs/geometry/test/util/select_most_precise.cpp23
5 files changed, 594 insertions, 97 deletions
diff --git a/libs/geometry/test/util/Jamfile.v2 b/libs/geometry/test/util/Jamfile.v2
index bfb647dc7..70a463777 100644
--- a/libs/geometry/test/util/Jamfile.v2
+++ b/libs/geometry/test/util/Jamfile.v2
@@ -1,11 +1,11 @@
# Boost.Geometry (aka GGL, Generic Geometry Library)
#
-# Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
-# Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
-# Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
+# Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
+# Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
+# Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
#
-# This file was modified by Oracle on 2014.
-# Modifications copyright (c) 2014, Oracle and/or its affiliates.
+# This file was modified by Oracle on 2014, 2015.
+# Modifications copyright (c) 2014-2015, Oracle and/or its affiliates.
#
# Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
#
@@ -18,6 +18,7 @@ test-suite boost-geometry-util
[ run calculation_type.cpp ]
[ run for_each_coordinate.cpp ]
[ run math_sqrt.cpp ]
+ [ run promote_integral.cpp ]
[ run range.cpp ]
[ run rational.cpp ]
[ run select_most_precise.cpp ]
diff --git a/libs/geometry/test/util/as_range.cpp b/libs/geometry/test/util/as_range.cpp
deleted file mode 100644
index f8696eeca..000000000
--- a/libs/geometry/test/util/as_range.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-// Boost.Geometry (aka GGL, Generic Geometry Library)
-// Unit Test
-
-// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
-// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
-// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
-
-// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
-// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
-
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-
-#include <geometry_test_common.hpp>
-
-
-#include <boost/geometry/views/detail/range_type.hpp>
-#include <boost/geometry/util/as_range.hpp>
-
-#include <boost/geometry/core/cs.hpp>
-#include <boost/geometry/geometries/geometries.hpp>
-
-#include <boost/geometry/io/wkt/read.hpp>
-
-template <int D, typename Range>
-double sum(Range const& range)
-{
- double s = 0.0;
- for (typename boost::range_const_iterator<Range>::type it = boost::begin(range);
- it != boost::end(range); ++it)
- {
- s += bg::get<D>(*it);
- }
- return s;
-}
-
-template <typename G>
-void test_geometry(std::string const& wkt, double expected_x, double expected_y)
-{
- G geometry;
-
- // Declare a range-type, compatible with boost::range,
- // such that range_iterator etc could be called
- typedef typename bg::detail::range_type<G>::type range_type;
-
- bg::read_wkt(wkt, geometry);
-
- double s = sum<0>(bg::as_range<range_type>(geometry));
- BOOST_CHECK_CLOSE(s, expected_x, 0.001);
-
- s = sum<1>(bg::as_range<range_type>(geometry));
- BOOST_CHECK_CLOSE(s, expected_y, 0.001);
-}
-
-
-template <typename P>
-void test_all()
-{
- // As-range utility should consider a geometry as a range, so
- // linestring stays linestring
- test_geometry<bg::model::linestring<P> >("LINESTRING(1 2,3 4)", 4, 6);
-
- // polygon will only be outer-ring
- test_geometry<bg::model::polygon<P> >("POLYGON((1 2,3 4))", 4, 6);
- test_geometry<bg::model::polygon<P> >("POLYGON((1 2,3 4),(5 6,7 8,9 10))", 4, 6);
-
- // the utility is useful for:
- // - convex hull (holes do not count)
- // - envelope (idem)
-}
-
-int test_main(int, char* [])
-{
- test_all<bg::model::point<double, 2, bg::cs::cartesian> >();
-
- return 0;
-}
diff --git a/libs/geometry/test/util/promote_integral.cpp b/libs/geometry/test/util/promote_integral.cpp
new file mode 100644
index 000000000..92d1b8ce4
--- /dev/null
+++ b/libs/geometry/test/util/promote_integral.cpp
@@ -0,0 +1,547 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// Unit Test
+
+// Copyright (c) 2015, Oracle and/or its affiliates.
+
+// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
+
+// Licensed under the Boost Software License version 1.0.
+// http://www.boost.org/users/license.html
+
+#ifndef BOOST_TEST_MODULE
+#define BOOST_TEST_MODULE test_promote_integral
+#endif
+
+#include <climits>
+#include <cstddef>
+#include <algorithm>
+#include <limits>
+#include <iostream>
+#include <string>
+#include <sstream>
+
+#include <boost/test/included/unit_test.hpp>
+
+#include <boost/config.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/is_unsigned.hpp>
+
+#include <geometry_test_common.hpp>
+
+#include <boost/geometry/util/condition.hpp>
+#include <boost/geometry/util/promote_integral.hpp>
+
+#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER)
+#include <boost/multiprecision/cpp_int.hpp>
+#endif
+
+#if defined(BOOST_GEOMETRY_TEST_DEBUG)
+#if defined(BOOST_HAS_INT128) && defined(BOOST_GEOMETRY_ENABLE_INT128)
+void print_uint128_t(std::ostream& os, boost::uint128_type i)
+{
+ if (i == 0)
+ {
+ os << "0";
+ return;
+ }
+
+ std::stringstream stream;
+ while (i > 0)
+ {
+ stream << static_cast<int>(i % 10);
+ i /= 10;
+ }
+ std::string str = stream.str();
+ std::reverse(str.begin(), str.end());
+ os << str;
+}
+
+std::ostream& operator<<(std::ostream& os, boost::int128_type i)
+{
+ if (i < 0)
+ {
+ os << "-";
+ print_uint128_t(os, static_cast<boost::uint128_type>(-i));
+ }
+ else
+ {
+ print_uint128_t(os, static_cast<boost::uint128_type>(i));
+ }
+ return os;
+}
+
+std::ostream& operator<<(std::ostream& os, boost::uint128_type i)
+{
+ print_uint128_t(os, i);
+ return os;
+}
+#endif // BOOST_HAS_INT128 && BOOST_GEOMETRY_ENABLE_INT128
+#endif // BOOST_GEOMETRY_TEST_DEBUG
+
+namespace bg = boost::geometry;
+
+template
+<
+ typename T,
+ bool Signed = boost::is_fundamental<T>::type::value
+ && ! boost::is_unsigned<T>::type::value
+>
+struct absolute_value
+{
+ static inline T apply(T const& t)
+ {
+ return t < 0 ? -t : t;
+ }
+};
+
+template <typename T>
+struct absolute_value<T, false>
+{
+ static inline T apply(T const& t)
+ {
+ return t;
+ }
+};
+
+
+
+template
+<
+ typename Integral,
+ typename Promoted,
+ bool Signed = ! boost::is_unsigned<Promoted>::type::value
+>
+struct test_max_values
+{
+ static inline void apply()
+ {
+ Promoted min_value = (std::numeric_limits<Integral>::min)();
+ min_value *= min_value;
+ BOOST_CHECK(absolute_value<Promoted>::apply(min_value) == min_value);
+ Promoted max_value = (std::numeric_limits<Integral>::max)();
+ max_value *= max_value;
+ BOOST_CHECK(absolute_value<Promoted>::apply(max_value) == max_value);
+
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ std::cout << "integral min_value^2: " << min_value << std::endl;
+ std::cout << "promoted max_value: "
+ << (std::numeric_limits<Promoted>::max)() << std::endl;
+#endif
+ }
+};
+
+template <typename Integral, typename Promoted>
+struct test_max_values<Integral, Promoted, false>
+{
+ static inline void apply()
+ {
+ Promoted max_value = (std::numeric_limits<Integral>::max)();
+ Promoted max_value_sqr = max_value * max_value;
+ BOOST_CHECK(max_value_sqr < (std::numeric_limits<Promoted>::max)()
+ &&
+ max_value_sqr > max_value);
+
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ std::cout << "integral max_value^2: " << max_value_sqr << std::endl;
+ std::cout << "promoted max_value: "
+ << (std::numeric_limits<Promoted>::max)() << std::endl;
+#endif
+ }
+};
+
+
+// helper function that returns the bit size of a type
+template
+<
+ typename T,
+ bool IsFundamental = boost::is_fundamental<T>::type::value
+>
+struct bit_size_impl : boost::mpl::size_t<0>
+{};
+
+template <typename T>
+struct bit_size_impl<T, true> : bg::detail::promote_integral::bit_size<T>::type
+{};
+
+#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER)
+template
+<
+ typename Backend,
+ boost::multiprecision::expression_template_option ExpressionTemplates
+>
+struct bit_size_impl
+ <
+ boost::multiprecision::number<Backend, ExpressionTemplates>,
+ false
+ > : bg::detail::promote_integral::bit_size
+ <
+ boost::multiprecision::number<Backend, ExpressionTemplates>
+ >
+{};
+#endif
+
+
+template <typename T>
+std::size_t bit_size()
+{
+ return bit_size_impl<T>::type::value;
+}
+
+template <bool PromoteUnsignedToUnsigned>
+struct test_promote_integral
+{
+ template <typename Type, typename ExpectedPromotedType>
+ static inline void apply(std::string const& case_id)
+ {
+ typedef typename bg::promote_integral
+ <
+ Type, PromoteUnsignedToUnsigned
+ >::type promoted_integral_type;
+
+ bool const same_types = boost::is_same
+ <
+ promoted_integral_type, ExpectedPromotedType
+ >::type::value;
+
+ BOOST_CHECK_MESSAGE(same_types,
+ "case ID: " << case_id
+ << "input type: " << typeid(Type).name()
+ << "; detected: "
+ << typeid(promoted_integral_type).name()
+ << "; expected: "
+ << typeid(ExpectedPromotedType).name());
+
+ if (BOOST_GEOMETRY_CONDITION((! boost::is_same
+ <
+ Type, promoted_integral_type
+ >::type::value)))
+ {
+ test_max_values<Type, promoted_integral_type>::apply();
+ }
+
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ std::cout << "case ID: " << case_id << std::endl
+ << "type : " << typeid(Type).name()
+ << ", sizeof (bits): " << bit_size<Type>()
+ << ", min value: "
+ << (std::numeric_limits<Type>::min)()
+ << ", max value: "
+ << (std::numeric_limits<Type>::max)()
+ << std::endl;
+ std::cout << "detected promoted type : "
+ << typeid(promoted_integral_type).name()
+ << ", sizeof (bits): " << bit_size<promoted_integral_type>()
+ << ", min value: "
+ << (std::numeric_limits<promoted_integral_type>::min)()
+ << ", max value: "
+ << (std::numeric_limits<promoted_integral_type>::max)()
+ << std::endl;
+ std::cout << "expected promoted type : "
+ << typeid(ExpectedPromotedType).name()
+ << ", sizeof (bits): " << bit_size<ExpectedPromotedType>()
+ << ", min value: "
+ << (std::numeric_limits<ExpectedPromotedType>::min)()
+ << ", max value: "
+ << (std::numeric_limits<ExpectedPromotedType>::max)()
+ << std::endl;
+ std::cout << std::endl;
+#endif
+ }
+};
+
+template
+<
+ typename T,
+ bool PromoteUnsignedToUnsigned = false,
+ bool IsSigned = ! boost::is_unsigned<T>::type::value
+>
+struct test_promotion
+{
+ static inline void apply(std::string case_id)
+ {
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ std::cout << "*** "
+ << (IsSigned ? "signed" : "unsigned")
+ << " -> signed ***" << std::endl;
+#endif
+
+ typedef test_promote_integral<PromoteUnsignedToUnsigned> tester;
+
+ case_id += (PromoteUnsignedToUnsigned ? "-t" : "-f");
+
+ std::size_t min_size = 2 * bit_size<T>() - 1;
+ if (BOOST_GEOMETRY_CONDITION(! IsSigned))
+ {
+ min_size += 2;
+ }
+
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ std::cout << "min size: " << min_size << std::endl;
+#endif
+
+ if (bit_size<short>() >= min_size)
+ {
+ tester::template apply<T, short>(case_id);
+ }
+ else if (bit_size<int>() >= min_size)
+ {
+ tester::template apply<T, int>(case_id);
+ }
+ else if (bit_size<long>() >= min_size)
+ {
+ tester::template apply<T, long>(case_id);
+ }
+#if defined(BOOST_HAS_LONG_LONG)
+ else if (bit_size<boost::long_long_type>() >= min_size)
+ {
+ tester::template apply<T, boost::long_long_type>(case_id);
+ }
+#endif
+#if defined(BOOST_HAS_INT128) && defined(BOOST_GEOMETRY_ENABLE_INT128)
+ else if (bit_size<boost::int128_type>() >= min_size)
+ {
+ tester::template apply<T, boost::int128_type>(case_id);
+ }
+#endif
+ else
+ {
+#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER)
+ namespace bm = boost::multiprecision;
+ typedef bm::number
+ <
+ bm::cpp_int_backend
+ <
+ 2 * CHAR_BIT * sizeof(T) + (IsSigned ? -1 : 1),
+ 2 * CHAR_BIT * sizeof(T) + (IsSigned ? -1 : 1),
+ bm::signed_magnitude,
+ bm::unchecked,
+ void
+ >
+ > multiprecision_integer_type;
+
+ tester::template apply<T, multiprecision_integer_type>(case_id);
+#else
+ tester::template apply<T, T>(case_id);
+#endif
+ }
+ }
+};
+
+template <typename T>
+struct test_promotion<T, true, false>
+{
+ static inline void apply(std::string case_id)
+ {
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ std::cout << "*** unsigned -> unsigned ***" << std::endl;
+#endif
+ case_id += "-t";
+
+ typedef test_promote_integral<true> tester;
+
+ std::size_t min_size = 2 * bit_size<T>();
+
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ std::cout << "min size: " << min_size << std::endl;
+#endif
+
+ if (bit_size<unsigned short>() >= min_size)
+ {
+ tester::apply<T, unsigned short>(case_id);
+ }
+ else if (bit_size<unsigned int>() >= min_size)
+ {
+ tester::apply<T, unsigned int>(case_id);
+ }
+ else if (bit_size<unsigned long>() >= min_size)
+ {
+ tester::apply<T, unsigned long>(case_id);
+ }
+ else if (bit_size<std::size_t>() >= min_size)
+ {
+ tester::apply<T, std::size_t>(case_id);
+ }
+#if defined(BOOST_HAS_LONG_LONG)
+ else if (bit_size<boost::ulong_long_type>() >= min_size)
+ {
+ tester::template apply<T, boost::ulong_long_type>(case_id);
+ }
+#endif
+#if defined(BOOST_HAS_INT128) && defined(BOOST_GEOMETRY_ENABLE_INT128)
+ else if (bit_size<boost::uint128_type>() >= min_size)
+ {
+ tester::template apply<T, boost::uint128_type>(case_id);
+ }
+#endif
+ else
+ {
+#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER)
+ namespace bm = boost::multiprecision;
+ typedef bm::number
+ <
+ bm::cpp_int_backend
+ <
+ 2 * CHAR_BIT * sizeof(T),
+ 2 * CHAR_BIT * sizeof(T),
+ bm::unsigned_magnitude,
+ bm::unchecked,
+ void
+ >
+ > multiprecision_integer_type;
+
+ tester::apply<T, multiprecision_integer_type>(case_id);
+#else
+ tester::apply<T, T>(case_id);
+#endif
+ }
+ }
+};
+
+
+
+BOOST_AUTO_TEST_CASE( test_char )
+{
+ test_promotion<char>::apply("char");
+ test_promotion<char, true>::apply("char");
+ test_promotion<signed char>::apply("schar");
+ test_promotion<signed char, true>::apply("schar");
+ test_promotion<unsigned char>::apply("uchar");
+ test_promotion<unsigned char, true>::apply("uchar");
+}
+
+BOOST_AUTO_TEST_CASE( test_short )
+{
+ test_promotion<short>::apply("short");
+ test_promotion<short, true>::apply("short");
+ test_promotion<unsigned short>::apply("ushort");
+ test_promotion<unsigned short, true>::apply("ushort");
+}
+
+BOOST_AUTO_TEST_CASE( test_int )
+{
+ test_promotion<int>::apply("int");
+ test_promotion<int, true>::apply("int");
+ test_promotion<unsigned int>::apply("uint");
+ test_promotion<unsigned int, true>::apply("uint");
+}
+
+BOOST_AUTO_TEST_CASE( test_long )
+{
+ test_promotion<long>::apply("long");
+ test_promotion<long, true>::apply("long");
+ test_promotion<unsigned long>::apply("ulong");
+ test_promotion<unsigned long, true>::apply("ulong");
+}
+
+BOOST_AUTO_TEST_CASE( test_std_size_t )
+{
+ test_promotion<std::size_t>::apply("size_t");
+ test_promotion<std::size_t, true>::apply("size_t");
+}
+
+#ifdef BOOST_HAS_LONG_LONG
+BOOST_AUTO_TEST_CASE( test_long_long )
+{
+ test_promotion<boost::long_long_type>::apply("long long");
+ test_promotion<boost::long_long_type, true>::apply("long long");
+ test_promotion<boost::ulong_long_type>::apply("ulong long");
+ test_promotion<boost::ulong_long_type, true>::apply("ulong long");
+}
+#endif
+
+#if defined(BOOST_HAS_INT128) && defined(BOOST_GEOMETRY_ENABLE_INT128)
+BOOST_AUTO_TEST_CASE( test_int128 )
+{
+ test_promotion<boost::int128_type>::apply("int128_t");
+ test_promotion<boost::int128_type, true>::apply("int128_t");
+ test_promotion<boost::uint128_type>::apply("uint128_t");
+ test_promotion<boost::uint128_type, true>::apply("uint128_t");
+}
+#endif
+
+#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER)
+BOOST_AUTO_TEST_CASE( test_user_types )
+{
+ namespace bm = boost::multiprecision;
+ typedef bm::number
+ <
+ bm::cpp_int_backend
+ <
+ 17,
+ 17,
+ bm::signed_magnitude,
+ bm::unchecked,
+ void
+ >
+ > user_signed_type1;
+
+ typedef bm::number
+ <
+ bm::cpp_int_backend
+ <
+ 17,
+ 17,
+ bm::unsigned_magnitude,
+ bm::unchecked,
+ void
+ >
+ > user_unsigned_type1;
+
+ typedef bm::number
+ <
+ bm::cpp_int_backend
+ <
+ 500,
+ 500,
+ bm::signed_magnitude,
+ bm::unchecked,
+ void
+ >
+ > user_signed_type2;
+
+ typedef bm::number
+ <
+ bm::cpp_int_backend
+ <
+ 500,
+ 500,
+ bm::unsigned_magnitude,
+ bm::unchecked,
+ void
+ >
+ > user_unsigned_type2;
+
+ // for user defined number types we do not do any promotion
+ typedef test_promote_integral<true> tester1;
+ typedef test_promote_integral<false> tester2;
+ tester1::apply<user_signed_type1, user_signed_type1>("u1s");
+ tester1::apply<user_signed_type2, user_signed_type2>("u2s");
+ tester1::apply<user_unsigned_type1, user_unsigned_type1>("u1u");
+ tester1::apply<user_unsigned_type2, user_unsigned_type2>("u2u");
+
+ tester2::apply<user_signed_type1, user_signed_type1>("u1s");
+ tester2::apply<user_signed_type2, user_signed_type2>("u2s");
+ tester2::apply<user_unsigned_type1, user_unsigned_type1>("u1u");
+ tester2::apply<user_unsigned_type2, user_unsigned_type2>("u1u");
+}
+#endif
+
+BOOST_AUTO_TEST_CASE( test_floating_point )
+{
+ typedef test_promote_integral<true> tester1;
+ typedef test_promote_integral<false> tester2;
+
+ // for floating-point types we do not do any promotion
+ tester1::apply<float, float>("fp-f");
+ tester1::apply<double, double>("fp-d");
+ tester1::apply<long double, long double>("fp-ld");
+
+ tester2::apply<float, float>("fp-f");
+ tester2::apply<double, double>("fp-d");
+ tester2::apply<long double, long double>("fp-ld");
+
+#ifdef HAVE_TTMATH
+ tester1::apply<ttmath_big, ttmath_big>("fp-tt");
+ tester2::apply<ttmath_big, ttmath_big>("fp-tt");
+#endif
+}
diff --git a/libs/geometry/test/util/range.cpp b/libs/geometry/test/util/range.cpp
index b2813a86d..c96464abe 100644
--- a/libs/geometry/test/util/range.cpp
+++ b/libs/geometry/test/util/range.cpp
@@ -1,7 +1,7 @@
// Boost.Geometry
// Unit Test
-// Copyright (c) 2014 Oracle and/or its affiliates.
+// Copyright (c) 2014-2015 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
@@ -12,6 +12,7 @@
#include <geometry_test_common.hpp>
+#include <iterator>
#include <vector>
#include <boost/geometry/util/range.hpp>
@@ -135,35 +136,35 @@ void test_all()
BOOST_CHECK(bgr::at(v, 1) == 1);
BOOST_CHECK(bgr::at(v, 2) == 3);
BOOST_CHECK(bgr::back(v) == 9);
- BOOST_CHECK(it == begin(v) + 2);
+ BOOST_CHECK(it == bgr::pos(v, 2));
it = bgr::erase(v, begin(v) + 2, begin(v) + 2);
BOOST_CHECK(boost::size(v) == 9); // {0,1,3..9}
BOOST_CHECK(bgr::at(v, 1) == 1);
BOOST_CHECK(bgr::at(v, 2) == 3);
BOOST_CHECK(bgr::back(v) == 9);
- BOOST_CHECK(it == begin(v) + 2);
+ BOOST_CHECK(it == bgr::pos(v, 2));
it = bgr::erase(v, begin(v) + 2, begin(v) + 5);
BOOST_CHECK(boost::size(v) == 6); // {0,1,6..9}
BOOST_CHECK(bgr::at(v, 1) == 1);
BOOST_CHECK(bgr::at(v, 2) == 6);
BOOST_CHECK(bgr::back(v) == 9);
- BOOST_CHECK(it == begin(v) + 2);
+ BOOST_CHECK(it == bgr::pos(v, 2));
it = bgr::erase(v, begin(v));
BOOST_CHECK(boost::size(v) == 5); // {1,6..9}
BOOST_CHECK(bgr::at(v, 0) == 1);
BOOST_CHECK(bgr::at(v, 1) == 6);
BOOST_CHECK(bgr::back(v) == 9);
- BOOST_CHECK(it == begin(v));
+ BOOST_CHECK(it == bgr::pos(v, 0));
it = bgr::erase(v, begin(v), begin(v) + 3);
BOOST_CHECK(boost::size(v) == 2); // {8,9}
BOOST_CHECK(bgr::at(v, 0) == 8);
BOOST_CHECK(bgr::at(v, 1) == 9);
BOOST_CHECK(bgr::back(v) == 9);
- BOOST_CHECK(it == begin(v));
+ BOOST_CHECK(it == bgr::pos(v, 0));
it = bgr::erase(v, begin(v), end(v));
BOOST_CHECK(boost::size(v) == 0);
@@ -198,6 +199,22 @@ void test_detail()
#endif
}
+template <class Iterator>
+void test_pointers()
+{
+ int arr[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+
+ boost::iterator_range<Iterator> r1(arr, arr + 10);
+ std::pair<Iterator, Iterator> r2(arr, arr + 10);
+
+ BOOST_CHECK(bgr::front(r1) == 0);
+ BOOST_CHECK(bgr::front(r2) == 0);
+ BOOST_CHECK(bgr::back(r1) == 9);
+ BOOST_CHECK(bgr::back(r2) == 9);
+ BOOST_CHECK(bgr::at(r1, 5) == 5);
+ BOOST_CHECK(bgr::at(r2, 5) == 5);
+}
+
int test_main(int, char* [])
{
test_all<int, true>();
@@ -211,6 +228,8 @@ int test_main(int, char* [])
test_all<bgt::CopyableAndMovable, false>();
test_detail();
+ test_pointers<int*>();
+ test_pointers<int const*>();
return 0;
}
diff --git a/libs/geometry/test/util/select_most_precise.cpp b/libs/geometry/test/util/select_most_precise.cpp
index 11b066fa3..3ec2dec73 100644
--- a/libs/geometry/test/util/select_most_precise.cpp
+++ b/libs/geometry/test/util/select_most_precise.cpp
@@ -24,8 +24,15 @@ template <typename T1, typename T2, typename ExpectedType>
void test()
{
typedef typename bg::select_most_precise<T1, T2>::type type;
-
- BOOST_CHECK((boost::is_same<type, ExpectedType>::type::value));
+ bool is_same = boost::is_same<type, ExpectedType>::type::value;
+
+ BOOST_CHECK_MESSAGE(is_same,
+ "The most precise of types " <<
+ "T1: {" << typeid(T1).name() << " | s: " << sizeof(T1) << "}" <<
+ " and " <<
+ "T2: {" << typeid(T2).name() << " | s: " << sizeof(T2) << "}" <<
+ " does not match " <<
+ "ExpectedType: {" << typeid(ExpectedType).name() << " | s: " << sizeof(ExpectedType) << "}");
}
int test_main(int, char* [])
@@ -49,11 +56,13 @@ int test_main(int, char* [])
test<float, int, float>();
test<int, float, float>();
-#ifndef _MSC_VER
- // This cannot be done for MSVC because double/long double is the same
- test<double, long double, long double>();
- test<long double, double, long double>();
-#endif
+ if ( sizeof(long double) > sizeof(double) )
+ {
+ // This cannot be done for MSVC because double/long double is the same
+ // This is also true for Android
+ test<double, long double, long double>();
+ test<long double, double, long double>();
+ }
// with any other non-integer/float class
test<int, user_defined, user_defined>();