| 1 | /* |
| 2 | Copyright (c) 2020, 2026, Oracle and/or its affiliates. |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License, version 2.0, |
| 6 | as published by the Free Software Foundation. |
| 7 | |
| 8 | This program is designed to work with certain software (including |
| 9 | but not limited to OpenSSL) that is licensed under separate terms, |
| 10 | as designated in a particular file or component or in included license |
| 11 | documentation. The authors of MySQL hereby grant you an additional |
| 12 | permission to link the program and your derivative works with the |
| 13 | separately licensed software that they have either included with |
| 14 | the program or referenced in the documentation. |
| 15 | |
| 16 | This program is distributed in the hope that it will be useful, |
| 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | GNU General Public License, version 2.0, for more details. |
| 20 | |
| 21 | You should have received a copy of the GNU General Public License |
| 22 | along with this program; if not, write to the Free Software |
| 23 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 24 | */ |
| 25 | |
| 26 | #include "my_config.h" |
| 27 | |
| 28 | #include <gtest/gtest.h> |
| 29 | #include <memory> // unique_ptr |
| 30 | |
| 31 | #include "sql/dd/dd.h" |
| 32 | #include "sql/dd/impl/types/spatial_reference_system_impl.h" |
| 33 | #include "sql/dd/properties.h" |
| 34 | #include "sql/dd/types/spatial_reference_system.h" |
| 35 | #include "sql/gis/geometries.h" |
| 36 | #include "sql/gis/geometries_cs.h" |
| 37 | #include "sql/gis/setops.h" |
| 38 | #include "unittest/gunit/gis_setops_testshapes.h" |
| 39 | #include "unittest/gunit/gis_test.h" |
| 40 | #include "unittest/gunit/gis_typeset.h" |
| 41 | |
| 42 | namespace gis_setops_unittest { |
| 43 | |
| 44 | template <typename Types> |
| 45 | struct SetopsTest : Gis_test<Types> {}; |
| 46 | |
| 47 | TYPED_TEST_SUITE(SetopsTest, gis_typeset::Test_both); |
| 48 | |
| 49 | // The purpose of this test is to cover all type combinations, not to check if |
| 50 | // the results are correct. |
| 51 | TYPED_TEST(SetopsTest, CodeCoverage) { |
| 52 | typename TypeParam::Geometrycollection gc; |
| 53 | |
| 54 | typename TypeParam::Point pt{0.0, 0.0}; |
| 55 | typename TypeParam::Linestring ls = simple_ls<TypeParam>(); |
| 56 | typename TypeParam::Polygon py = base_py<TypeParam>(); |
| 57 | typename TypeParam::Multipoint mpt = simple_mpt<TypeParam>(); |
| 58 | typename TypeParam::Multilinestring mls = simple_mls<TypeParam>(); |
| 59 | typename TypeParam::Multipolygon mpy = simple_mpy<TypeParam>(); |
| 60 | typename TypeParam::Geometrycollection gc_empty; |
| 61 | typename TypeParam::Geometrycollection gc_inner; |
| 62 | gc_inner.push_back(pt); |
| 63 | |
| 64 | gc.push_back(gc_empty); |
| 65 | gc.push_back(gc_inner); |
| 66 | gc.push_back(pt); |
| 67 | gc.push_back(ls); |
| 68 | gc.push_back(py); |
| 69 | gc.push_back(mpt); |
| 70 | gc.push_back(mls); |
| 71 | gc.push_back(mpy); |
| 72 | |
| 73 | for (auto g1 : gc) { |
| 74 | for (auto g2 : gc) { |
| 75 | std::unique_ptr<gis::Geometry> result; |
| 76 | bool is_null = false; |
| 77 | gis::difference(this->m_srs.get(), g1, g2, "unittest", &result); |
| 78 | gis::intersection(this->m_srs.get(), g1, g2, "unittest", &result); |
| 79 | gis::symdifference(this->m_srs.get(), g1, g2, "unittest", &result); |
| 80 | gis::union_(this->m_srs.get(), g1, g2, "unittest", &result, &is_null); |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | } // namespace gis_setops_unittest |