]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/geometry/test/robustness/overlay/areal_areal/star_comb.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / geometry / test / robustness / overlay / areal_areal / star_comb.cpp
index 40bec4052cf04e770c14c3d9c0dc9c1cad8fefc7..19e5350a2f640ae52165519da23b6d0da8a45e9e 100644 (file)
@@ -1,26 +1,25 @@
 // Boost.Geometry (aka GGL, Generic Geometry Library)
-// Unit Test
+// 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)
 
-
-// #define BOOST_GEOMETRY_REPORT_OVERLAY_ERROR
 #define BOOST_GEOMETRY_NO_BOOST_TEST
-// #define BOOST_GEOMETRY_TIME_OVERLAY
-
 
 #include <test_overlay_p_q.hpp>
 
+#include <chrono>
+#include <fstream>
+#include <sstream>
+
 #include <boost/program_options.hpp>
 #include <boost/random/linear_congruential.hpp>
 #include <boost/random/uniform_int.hpp>
 #include <boost/random/uniform_real.hpp>
 #include <boost/random/variate_generator.hpp>
-#include <boost/timer.hpp>
 
 #include <star_comb.hpp>
 
@@ -34,15 +33,15 @@ void add(Polygon& polygon, double x, double y, int)
 
 
 template <typename Polygon>
-void test_star_comb(int star_point_count, int comb_comb_count, double factor1, double factor2, bool do_union, p_q_settings const& settings)
+bool test_star_comb(int index, int star_point_count, int comb_comb_count, double factor1, double factor2, bool do_union, p_q_settings const& settings)
 {
     Polygon star, comb;
     make_star(star, add<Polygon>, star_point_count, factor1, factor2);
     make_comb(comb, add<Polygon>, comb_comb_count);
 
     std::ostringstream out;
-    out << "star_comb";
-    test_overlay_p_q
+    out << "star_comb_" << index;
+    return test_overlay_p_q
         <
             Polygon,
             typename bg::coordinate_type<Polygon>::type
@@ -53,24 +52,33 @@ void test_star_comb(int star_point_count, int comb_comb_count, double factor1, d
 template <typename T, bool Clockwise, bool Closed>
 void test_all(int count, int star_point_count, int comb_comb_count, double factor1, double factor2, bool do_union, p_q_settings const& settings)
 {
-    boost::timer t;
+    auto const t0 = std::chrono::high_resolution_clock::now();
 
     typedef bg::model::polygon
         <
             bg::model::d2::point_xy<T>, Clockwise, Closed
         > polygon;
 
+    int errors = 0;
     for(int i = 0; i < count; i++)
     {
-        test_star_comb<polygon>(star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
+        if (! test_star_comb<polygon>(i, star_point_count, comb_comb_count, factor1, factor2, do_union, settings))
+        {
+            errors++;
+        }
     }
+    auto const t = std::chrono::high_resolution_clock::now();
+    auto const elapsed_ms = std::chrono::duration_cast<std::chrono::milliseconds>(t - t0).count();
     std::cout
+        << "geometries: " << count
+        << " errors: " << errors
         << " type: " << string_from_type<T>::name()
-        << " time: " << t.elapsed()  << std::endl;
+        << " time: " << elapsed_ms / 1000.0 << std::endl;
 }
 
 int main(int argc, char** argv)
 {
+    BoostGeometryWriteTestConfiguration();
     try
     {
         namespace po = boost::program_options;
@@ -112,24 +120,20 @@ int main(int argc, char** argv)
 
         if (ccw && open)
         {
-            test_all<double, false, false>(count, star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
+            test_all<default_test_type, false, false>(count, star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
         }
         else if (ccw)
         {
-            test_all<double, false, true>(count, star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
+            test_all<default_test_type, false, true>(count, star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
         }
         else if (open)
         {
-            test_all<double, true, false>(count, star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
+            test_all<default_test_type, true, false>(count, star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
         }
         else
         {
-            test_all<double, true, true>(count, star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
+            test_all<default_test_type, true, true>(count, star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
         }
-
-#if defined(HAVE_TTMATH)
-        // test_all<ttmath_big, true, true>(seed, count, max, svg, level);
-#endif
     }
     catch(std::exception const& e)
     {