X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fboost%2Flibs%2Fgeometry%2Ftest%2Falgorithms%2Fbuffer%2Ftest_buffer.hpp;fp=ceph%2Fsrc%2Fboost%2Flibs%2Fgeometry%2Ftest%2Falgorithms%2Fbuffer%2Ftest_buffer.hpp;h=3f1581635e0f4c84178df9bfc383c5b4a2363b9c;hb=20effc670b57271cb089376d6d0800990e5218d5;hp=3b745996ed422d89bc347412889f033fe2739b4e;hpb=a71831dadd1e1f3e0fa70405511f65cc33db0498;p=ceph.git diff --git a/ceph/src/boost/libs/geometry/test/algorithms/buffer/test_buffer.hpp b/ceph/src/boost/libs/geometry/test/algorithms/buffer/test_buffer.hpp index 3b745996e..3f1581635 100644 --- a/ceph/src/boost/libs/geometry/test/algorithms/buffer/test_buffer.hpp +++ b/ceph/src/boost/libs/geometry/test/algorithms/buffer/test_buffer.hpp @@ -25,7 +25,8 @@ #include #include -#include "geometry_test_common.hpp" +#include +#include #include #include @@ -95,17 +96,11 @@ template<> struct EndTestProperties static std::string name() { return "flat"; } }; -struct ut_settings +struct ut_settings : public ut_base_settings { - double tolerance; - bool test_validity; - bool test_area; - bool use_ln_area; - int points_per_circle; - explicit ut_settings(double tol = 0.01, bool val = true, int points = 88) - : tolerance(tol) - , test_validity(val) + : ut_base_settings(val) + , tolerance(tol) , test_area(true) , use_ln_area(false) , points_per_circle(points) @@ -114,19 +109,24 @@ struct ut_settings static inline ut_settings ignore_validity() { ut_settings result; - result.test_validity = false; + result.set_test_validity(false); return result; } static inline ut_settings assertions_only() { ut_settings result; - result.test_validity = false; result.test_area = false; + result.set_test_validity(false); return result; } static inline double ignore_area() { return 9999.9; } + + double tolerance; + bool test_area; + bool use_ln_area; + int points_per_circle; }; template @@ -151,7 +151,7 @@ void test_buffer(std::string const& caseid, AreaStrategy const& area_strategy, int expected_count, int expected_holes_count, - double expected_area, + expectation_limits const& expected_area, ut_settings const& settings) { namespace bg = boost::geometry; @@ -268,7 +268,7 @@ void test_buffer(std::string const& caseid, //std::cout << complete.str() << "," << std::fixed << std::setprecision(0) << area << std::endl; //return; - if (bg::is_empty(buffered) && bg::math::equals(expected_area, 0.0)) + if (bg::is_empty(buffered) && expected_area.is_zero()) { // As expected - don't get rescale policy for output (will be invalid) return; @@ -318,45 +318,19 @@ void test_buffer(std::string const& caseid, if (settings.test_area) { - // Because areas vary hugely in buffer, the Boost.Test methods are not convenient. - // Use just the abs - but if areas are really small that is not convenient neither. - // Therefore there is a logarithmic option too. - typename bg::default_area_result::type area = bg::area(buffered, area_strategy); - double const difference = settings.use_ln_area - ? std::log(area) - std::log(expected_area) - : area - expected_area; - BOOST_CHECK_MESSAGE - ( - bg::math::abs(difference) < settings.tolerance, - complete.str() << " not as expected. " - << std::setprecision(18) - << " Expected: " << expected_area - << " Detected: " << area - << " Diff: " << difference - << " Tol: " << settings.tolerance - << std::setprecision(3) - << " , " << 100.0 * (difference / expected_area) << "%" - ); -// if (settings.use_ln_area) -// { -// std::cout << complete.str() -// << std::setprecision(6) -// << " ln(detected)=" << std::log(area) -// << " ln(expected)=" << std::log(expected_area) -// << " diff=" << difference -// << " detected=" << area -// << std::endl; -// } + typename bg::default_area_result::type area + = bg::area(buffered, area_strategy); + BOOST_CHECK_MESSAGE(expected_area.contains(area, settings.tolerance, settings.use_ln_area), + "difference: " << caseid << std::setprecision(20) + << " #area expected: " << expected_area + << " detected: " << area + << " type: " << (type_for_assert_message()) + ); } -#if ! defined(BOOST_GEOMETRY_TEST_ALWAYS_CHECK_VALIDITY) - if (settings.test_validity) -#endif + if (settings.test_validity() && ! bg::is_valid(buffered)) { - if (! bg::is_valid(buffered)) - { - BOOST_CHECK_MESSAGE(bg::is_valid(buffered), complete.str() << " is not valid"); - } + BOOST_CHECK_MESSAGE(bg::is_valid(buffered), complete.str() << " is not valid"); } #if defined(TEST_WITH_SVG_PER_TURN) @@ -399,7 +373,7 @@ void test_buffer(std::string const& caseid, bg::model::multi_polygon void test_one(std::string const& caseid, std::string const& wkt, JoinStrategy const& join_strategy, EndStrategy const& end_strategy, - int expected_count, int expected_holes_count, double expected_area, + int expected_count, int expected_holes_count, expectation_limits const& expected_area, double distance_left, ut_settings const& settings = ut_settings(), double distance_right = same_distance) { @@ -472,10 +446,12 @@ void test_one(std::string const& caseid, std::string const& wkt, expected_count, expected_holes_count, expected_area, settings); -#if !defined(BOOST_GEOMETRY_COMPILER_MODE_DEBUG) && defined(BOOST_GEOMETRY_COMPILER_MODE_RELEASE) +#if !defined(BOOST_GEOMETRY_COMPILER_MODE_DEBUG) \ + && !defined(BOOST_GEOMETRY_TEST_ONLY_ONE_ORDER) \ + && defined(BOOST_GEOMETRY_COMPILER_MODE_RELEASE) // Also test symmetric distance strategy if right-distance is not specified - // (only in release mode) + // (only in release mode, not if "one order" if speficied) if (bg::math::equals(distance_right, same_distance)) { bg::strategy::buffer::distance_symmetric @@ -504,7 +480,7 @@ template > void test_one(std::string const& caseid, std::string const& wkt, JoinStrategy const& join_strategy, EndStrategy const& end_strategy, - double expected_area, + expectation_limits const& expected_area, double distance_left, ut_settings const& settings = ut_settings(), double distance_right = same_distance) { @@ -530,7 +506,7 @@ void test_with_custom_strategies(std::string const& caseid, DistanceStrategy const& distance_strategy, SideStrategy const& side_strategy, PointStrategy const& point_strategy, - double expected_area, + expectation_limits const& expected_area, ut_settings const& settings = ut_settings()) { namespace bg = boost::geometry;