From 3a5425ae29dffd53b5551a1c6b194a96139c2009 Mon Sep 17 00:00:00 2001 From: plaiseek Date: Wed, 25 Sep 2024 17:51:20 +0200 Subject: [PATCH] fuzzy test ok, TODO handle vertical segments --- test/bentley_ottmann_test.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/bentley_ottmann_test.cpp b/test/bentley_ottmann_test.cpp index 41070d2..e729146 100755 --- a/test/bentley_ottmann_test.cpp +++ b/test/bentley_ottmann_test.cpp @@ -1,6 +1,7 @@ #undef NDEBUG #include +#include #include #include "melon/experimental/bentley_ottmann.hpp" @@ -97,11 +98,23 @@ GTEST_TEST(bentley_ottmann, fuzzy_test) { std::declval(), std::declval()))::value_type; std::vector segments; + const std::size_t & num_segments = 100; + + std::random_device dev; + std::mt19937 rng(dev()); + std::uniform_int_distribution dist(-15, 15); + + for(std::size_t i = 0; i < num_segments; ++i) { + segments.emplace_back(std::make_pair(dist(rng), dist(rng)), + std::make_pair(dist(rng), dist(rng))); + if(segments.back().first.first == segments.back().second.first) + segments.pop_back(); + } std::vector>> intersections_vec; for(const auto & [i, intersecting_segments] : - bentley_ottmann(std::views::iota(0ul, segments.size()), segments)) { + bentley_ottmann(std::views::iota(0ul, num_segments), segments)) { intersections_vec.emplace_back(std::make_pair( i, std::vector(intersecting_segments.begin(), intersecting_segments.end())));