From 040636c6c336c6c176bb07455a343b82fba1e165 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 8 Jun 2022 00:55:11 +0200 Subject: [PATCH] [test][overlaps] Add tests for GC and DG --- test/algorithms/overlaps/Jamfile | 5 +- test/algorithms/overlaps/overlaps_gc.cpp | 58 ++++++++++++++++++++++ test/algorithms/overlaps/test_overlaps.hpp | 21 +++++--- 3 files changed, 74 insertions(+), 10 deletions(-) create mode 100644 test/algorithms/overlaps/overlaps_gc.cpp diff --git a/test/algorithms/overlaps/Jamfile b/test/algorithms/overlaps/Jamfile index ec744c76c..70ffdb541 100644 --- a/test/algorithms/overlaps/Jamfile +++ b/test/algorithms/overlaps/Jamfile @@ -4,8 +4,8 @@ # Copyright (c) 2008-2015 Bruno Lalande, Paris, France. # Copyright (c) 2009-2015 Mateusz Loskot, London, UK. # -# This file was modified by Oracle on 2014, 2015, 2016. -# Modifications copyright (c) 2014-2016, Oracle and/or its affiliates. +# This file was modified by Oracle on 2014-2022. +# Modifications copyright (c) 2014-2022, Oracle and/or its affiliates. # # Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle # Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -19,6 +19,7 @@ test-suite boost-geometry-algorithms-overlaps [ run overlaps.cpp : : : : algorithms_overlaps ] [ run overlaps_areal.cpp : : : : algorithms_overlaps_areal ] [ run overlaps_box.cpp : : : : algorithms_overlaps_box ] + [ run overlaps_gc.cpp : : : : algorithms_overlaps_gc ] [ run overlaps_sph.cpp : : : : algorithms_overlaps_sph ] ; diff --git a/test/algorithms/overlaps/overlaps_gc.cpp b/test/algorithms/overlaps/overlaps_gc.cpp new file mode 100644 index 000000000..07aaea34a --- /dev/null +++ b/test/algorithms/overlaps/overlaps_gc.cpp @@ -0,0 +1,58 @@ +// Boost.Geometry + +// Copyright (c) 2022 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, 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 +// http://www.boost.org/LICENSE_1_0.txt) + +#include "test_overlaps.hpp" + +using pt_t = bg::model::point; +using ls_t = bg::model::linestring; +using po_t = bg::model::polygon; +using mpt_t = bg::model::multi_point; +using mls_t = bg::model::multi_linestring; +using mpo_t = bg::model::multi_polygon; +using var_t = boost::variant; +//using var_t = boost::variant2::variant; +using gc_t = bg::model::geometry_collection; + +void test_gc() +{ + test_geometry("GEOMETRYCOLLECTION(MULTIPOINT(0 0,1 1,2 2))", + "GEOMETRYCOLLECTION(MULTIPOINT(1 1,3 3,4 4))", + true); + test_geometry("GEOMETRYCOLLECTION(MULTIPOINT(0 0,1 1,2 2))", + "GEOMETRYCOLLECTION(MULTIPOINT(1 1,2 2))", + false); + + test_geometry("GEOMETRYCOLLECTION(POINT(0 0), POINT(1 1), POINT(2 2))", + "GEOMETRYCOLLECTION(POINT(1 1), POINT(3 3), POINT(4 4))", + true); + test_geometry("GEOMETRYCOLLECTION(POINT(0 0), POINT(1 1), POINT(2 2))", + "GEOMETRYCOLLECTION(POINT(1 1), POINT(2 2))", + false); + + test_geometry("MULTIPOINT(0 0,1 1,2 2)", + "GEOMETRYCOLLECTION(MULTIPOINT(1 1,3 3,4 4))", + true); + test_geometry("GEOMETRYCOLLECTION(MULTIPOINT(0 0,1 1,2 2))", + "MULTIPOINT(1 1,2 2)", + false); + + test_geometry("GEOMETRYCOLLECTION(MULTIPOINT(0 0,1 1,2 2))", + "MULTIPOINT(1 1,3 3,4 4)", + true); + test_geometry("MULTIPOINT(0 0,1 1,2 2)", + "GEOMETRYCOLLECTION(MULTIPOINT(1 1,2 2))", + false); +} + +int test_main(int , char* []) +{ + test_gc(); + + return 0; +} diff --git a/test/algorithms/overlaps/test_overlaps.hpp b/test/algorithms/overlaps/test_overlaps.hpp index 7d6686986..b906b75d7 100644 --- a/test/algorithms/overlaps/test_overlaps.hpp +++ b/test/algorithms/overlaps/test_overlaps.hpp @@ -3,8 +3,8 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2015, 2017. -// Modifications copyright (c) 2015-2017 Oracle and/or its affiliates. +// This file was modified by Oracle on 2015-2022. +// Modifications copyright (c) 2015-2022 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, @@ -17,12 +17,10 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include #include @@ -82,12 +80,19 @@ void test_geometry(std::string const& wkt1, test_geometry(geometry1, geometry2, wkt1, wkt2, expected, no_strategy()); - typedef typename bg::strategy::relate::services::default_strategy + typedef typename bg::strategies::relate::services::default_strategy < Geometry1, Geometry2 >::type strategy_type; test_geometry(geometry1, geometry2, wkt1, wkt2, expected, strategy_type()); + + boost::variant v1 = geometry1; + boost::variant v2 = geometry2; + + test_geometry(v1, geometry2, wkt1, wkt2, expected, no_strategy()); + test_geometry(geometry1, v2, wkt1, wkt2, expected, no_strategy()); + test_geometry(v1, v2, wkt1, wkt2, expected, no_strategy()); }