From f77aeabc240ae16e7ac105fc57a78c8e6b8890b2 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 23 Sep 2020 13:59:07 +0200 Subject: [PATCH] [buffer][test] update robustness test for buffer --- test/robustness/common/common_settings.hpp | 23 +++++--------- .../buffer/recursive_polygons_buffer.cpp | 31 ++++++++++--------- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/test/robustness/common/common_settings.hpp b/test/robustness/common/common_settings.hpp index 2d4153a47..0c551d973 100644 --- a/test/robustness/common/common_settings.hpp +++ b/test/robustness/common/common_settings.hpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Robustness Test // -// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2020 Barend Gehrels, 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) @@ -11,22 +11,15 @@ struct common_settings { - bool svg; - bool wkt; - bool also_difference; - double tolerance; + bool svg{false}; + bool wkt{false}; + bool also_difference{false}; + double tolerance{1.0e-6}; - int field_size; - bool triangular; + int field_size{10}; + bool triangular{false}; - common_settings() - : svg(false) - , wkt(false) - , also_difference(false) - , tolerance(1.0e-6) - , field_size(10) - , triangular(false) - {} + bool check_validity{true}; }; #endif // BOOST_GEOMETRY_COMMON_SETTINGS_HPP diff --git a/test/robustness/overlay/buffer/recursive_polygons_buffer.cpp b/test/robustness/overlay/buffer/recursive_polygons_buffer.cpp index 952f81d95..420afb2a9 100644 --- a/test/robustness/overlay/buffer/recursive_polygons_buffer.cpp +++ b/test/robustness/overlay/buffer/recursive_polygons_buffer.cpp @@ -22,13 +22,14 @@ #include #include +#include + #include #include #include #include #include #include -#include #include #include @@ -113,7 +114,7 @@ bool verify(std::string const& caseid, MultiPolygon const& mp, MultiPolygon cons } } - if (result) + if (result && settings.check_validity) { bg::validity_failure_type failure; if (! bg::is_valid(buffer, failure) @@ -128,18 +129,11 @@ bool verify(std::string const& caseid, MultiPolygon const& mp, MultiPolygon cons bool wkt = settings.wkt; if (! result) { - std::cout << "ERROR " << caseid << std::endl; - //std::cout << bg::wkt(mp) << std::endl; - //std::cout << bg::wkt(buffer) << std::endl; + // The result is wrong, override settings to create a SVG and WKT svg = true; wkt = true; } - if (svg || wkt) - { - //std::cout << caseid << std::endl; - } - if (svg) { std::ostringstream filename; @@ -257,7 +251,7 @@ bool test_buffer(MultiPolygon& result, int& index, template void test_all(int seed, int count, int level, Settings const& settings) { - boost::timer t; + auto const t0 = std::chrono::high_resolution_clock::now(); typedef boost::minstd_rand base_generator_type; @@ -275,15 +269,23 @@ void test_all(int seed, int count, int level, Settings const& settings) int index = 0; + int errors = 0; for(int i = 0; i < count; i++) { mp p; - test_buffer(p, index, coordinate_generator, level, settings); + if (! test_buffer(p, index, coordinate_generator, level, settings)) + { + errors++; + } } + + auto const t = std::chrono::high_resolution_clock::now(); + auto const elapsed_ms = std::chrono::duration_cast(t - t0).count(); std::cout << "geometries: " << index + << " errors: " << errors << " type: " << typeid(T).name() - << " time: " << t.elapsed() << std::endl; + << " time: " << elapsed_ms / 1000.0 << std::endl; } int main(int argc, char** argv) @@ -292,7 +294,7 @@ int main(int argc, char** argv) try { namespace po = boost::program_options; - po::options_description description("=== recursive_polygons_linear_areal ===\nAllowed options"); + po::options_description description("=== recursive_polygons_buffer ===\nAllowed options"); int count = 1; int seed = static_cast(std::time(0)); @@ -316,6 +318,7 @@ int main(int argc, char** argv) ("size", po::value(&settings.field_size)->default_value(10), "Size of the field") ("wkt", po::value(&settings.wkt)->default_value(false), "Create a WKT of the inputs, for all tests") ("svg", po::value(&settings.svg)->default_value(false), "Create a SVG for all tests") + ("check_validity", po::value(&settings.check_validity)->default_value(true), "Check validity") ; po::variables_map varmap;