diff --git a/test/strategies/Jamfile.v2 b/test/strategies/Jamfile.v2 index 9475f6a5d..e994e46f0 100644 --- a/test/strategies/Jamfile.v2 +++ b/test/strategies/Jamfile.v2 @@ -1,8 +1,13 @@ # Boost.Geometry (aka GGL, Generic Geometry Library) # -# 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. +# 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. +# +# This file was modified by Oracle on 2014. +# Modifications copyright (c) 2014, Oracle and/or its affiliates. +# +# Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle # # Use, modification and distribution is subject to the Boost Software License, # Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -11,6 +16,7 @@ test-suite boost-geometry-strategies : [ run cross_track.cpp ] + [ run distance_default_result.cpp ] [ run haversine.cpp ] [ run projected_point.cpp ] [ run pythagoras.cpp ] diff --git a/test/strategies/distance_default_result.cpp b/test/strategies/distance_default_result.cpp new file mode 100644 index 000000000..40315d207 --- /dev/null +++ b/test/strategies/distance_default_result.cpp @@ -0,0 +1,270 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, 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_distance_default_result +#endif + +#include +#include + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#if defined(HAVE_TTMATH) +#include +#endif + +namespace bg = ::boost::geometry; + + +template +struct assert_equal_types +{ + assert_equal_types() + { + static const bool are_same = + boost::is_same::type::value; + + BOOST_MPL_ASSERT_MSG((are_same), + WRONG_DEFAULT_DISTANCE_RESULT, + (types)); + } +}; + +//========================================================================= + +template +< + typename Geometry1, + typename Geometry2, + typename ExpectedResult, + typename ExpectedComparableResult +> +inline void test_distance_result() +{ + typedef typename bg::default_distance_result + < + Geometry1, Geometry2 + >::type result12; + + typedef typename bg::default_distance_result + < + Geometry2, Geometry1 + >::type result21; + + typedef typename bg::default_comparable_distance_result + < + Geometry1, Geometry2 + >::type comparable_result12; + + typedef typename bg::default_comparable_distance_result + < + Geometry2, Geometry1 + >::type comparable_result21; + + assert_equal_types(); + assert_equal_types(); + assert_equal_types(); + assert_equal_types(); +} + +//========================================================================= + +template +< + typename CoordinateType1, + typename CoordinateType2, + std::size_t Dimension, + typename CoordinateSystem, + typename ExpectedResult, + typename ExpectedComparableResult = ExpectedResult +> +struct test_distance_result_segment +{ + test_distance_result_segment() + { + typedef typename bg::model::point + < + CoordinateType1, Dimension, CoordinateSystem + > point1; + + typedef typename bg::model::point + < + CoordinateType2, Dimension, CoordinateSystem + > point2; + + typedef typename bg::model::segment segment1; + typedef typename bg::model::segment segment2; + + test_distance_result + < + point1, point2, ExpectedResult, ExpectedComparableResult + >(); + + test_distance_result + < + point1, segment2, ExpectedResult, ExpectedComparableResult + >(); + + test_distance_result + < + point2, segment1, ExpectedResult, ExpectedComparableResult + >(); + } +}; + +//========================================================================= + +template +< + typename CoordinateType1, + typename CoordinateType2, + std::size_t Dimension, + typename ExpectedResult, + typename ExpectedComparableResult = ExpectedResult +> +struct test_distance_result_box +{ + test_distance_result_box() + { + typedef typename bg::model::point + < + CoordinateType1, Dimension, bg::cs::cartesian + > point1; + + typedef typename bg::model::point + < + CoordinateType2, Dimension, bg::cs::cartesian + > point2; + + typedef typename bg::model::box box1; + typedef typename bg::model::box box2; + + test_distance_result + < + point1, box2, ExpectedResult, ExpectedComparableResult + >(); + + test_distance_result + < + point2, box1, ExpectedResult, ExpectedComparableResult + >(); + + test_distance_result + < + box1, box2, ExpectedResult, ExpectedComparableResult + >(); + } +}; + +//========================================================================= + +template +inline void test_segment_all() +{ +#if defined(HAVE_TTMATH) + typedef ttmath_big tt; + typedef bg::util::detail::default_integral::type default_integral; +#endif + typedef typename boost::mpl::if_ + < + typename boost::is_same::type, + double, + float + >::type float_return_type; + + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + + test_distance_result_segment(); + test_distance_result_segment(); + + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + +#if defined(HAVE_TTMATH) + test_distance_result_segment(); + test_distance_result_segment(); + + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); +#endif +} + +//========================================================================= + +template +inline void test_box_all() +{ +#if defined(HAVE_TTMATH) + typedef ttmath_big tt; +#endif + typedef bg::util::detail::default_integral::type default_integral; + + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); + + test_distance_result_box(); + test_distance_result_box(); + + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); + +#if defined(HAVE_TTMATH) + test_distance_result_box(); + test_distance_result_box(); + + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); +#endif +} + +//========================================================================= + +BOOST_AUTO_TEST_CASE( test_point_point_or_point_segment ) +{ + test_segment_all<2, bg::cs::cartesian>(); + test_segment_all<3, bg::cs::cartesian>(); + test_segment_all<4, bg::cs::cartesian>(); + test_segment_all<2, bg::cs::spherical_equatorial >(); +} + +BOOST_AUTO_TEST_CASE( test_point_box_or_box ) +{ + test_box_all<2>(); + test_box_all<3>(); + test_box_all<4>(); +}