[geos-commits] [SCM] GEOS branch master updated. c3a65c9ae2363aca06945deb7b007101f3813888

git at osgeo.org git at osgeo.org
Tue Aug 25 15:07:38 PDT 2020


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, master has been updated
       via  c3a65c9ae2363aca06945deb7b007101f3813888 (commit)
       via  aac987dda9be5a4bcc4bd4a1abcd63211f89f99e (commit)
      from  c5f33f91a2eb631e3419a91f4f02076babacf00b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c3a65c9ae2363aca06945deb7b007101f3813888
Merge: aac987d c5f33f9
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Aug 25 15:07:31 2020 -0700

    Merge branch 'master' of https://git.osgeo.org/gitea/geos/geos


commit aac987dda9be5a4bcc4bd4a1abcd63211f89f99e
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Aug 25 15:07:24 2020 -0700

    Rename the utility test functions to ensure_* and change the struct name to reflect larger goals than just providing helper init/finish code

diff --git a/tests/unit/capi/GEOSBoundaryTest.cpp b/tests/unit/capi/GEOSBoundaryTest.cpp
index 1368155..b658833 100644
--- a/tests/unit/capi/GEOSBoundaryTest.cpp
+++ b/tests/unit/capi/GEOSBoundaryTest.cpp
@@ -9,7 +9,7 @@ namespace tut {
 // Test Group
 //
 
-struct test_geosboundary_data : public capitest::test_handlers {};
+struct test_geosboundary_data : public capitest::utility {};
 
 typedef test_group<test_geosboundary_data> group;
 typedef group::object object;
diff --git a/tests/unit/capi/GEOSEnvelopeTest.cpp b/tests/unit/capi/GEOSEnvelopeTest.cpp
index bc1a635..f1bbc0f 100644
--- a/tests/unit/capi/GEOSEnvelopeTest.cpp
+++ b/tests/unit/capi/GEOSEnvelopeTest.cpp
@@ -9,7 +9,7 @@ namespace tut {
 // Test Group
 //
 
-struct test_geosenvelope_data : public capitest::test_handlers {};
+struct test_geosenvelope_data : public capitest::utility {};
 
 typedef test_group<test_geosenvelope_data> group;
 typedef group::object object;
diff --git a/tests/unit/capi/GEOSGeomFromWKBTest.cpp b/tests/unit/capi/GEOSGeomFromWKBTest.cpp
index 2f6638a..e74f080 100644
--- a/tests/unit/capi/GEOSGeomFromWKBTest.cpp
+++ b/tests/unit/capi/GEOSGeomFromWKBTest.cpp
@@ -12,7 +12,7 @@ namespace tut {
 //
 
 // Common data used in test cases.
-struct test_capigeosgeomfromwkb_data : public capitest::test_handlers {
+struct test_capigeosgeomfromwkb_data : public capitest::utility {
     GEOSGeometry* geom1_;
     GEOSGeometry* geom2_;
     GEOSWKTReader* reader_;
diff --git a/tests/unit/capi/GEOSGeom_createLineStringTest.cpp b/tests/unit/capi/GEOSGeom_createLineStringTest.cpp
index 1061ce3..c9f6148 100644
--- a/tests/unit/capi/GEOSGeom_createLineStringTest.cpp
+++ b/tests/unit/capi/GEOSGeom_createLineStringTest.cpp
@@ -6,7 +6,7 @@ namespace tut {
 // Test Group
 //
 
-struct test_geosgeom_createlinestring_data : public capitest::test_handlers {};
+struct test_geosgeom_createlinestring_data : public capitest::utility {};
 
 typedef test_group<test_geosgeom_createlinestring_data> group;
 typedef group::object object;
diff --git a/tests/unit/capi/GEOSGeom_getCoordSeqTest.cpp b/tests/unit/capi/GEOSGeom_getCoordSeqTest.cpp
index 62b12b3..871ff87 100644
--- a/tests/unit/capi/GEOSGeom_getCoordSeqTest.cpp
+++ b/tests/unit/capi/GEOSGeom_getCoordSeqTest.cpp
@@ -9,7 +9,7 @@ namespace tut {
 // Test Group
 //
 
-struct test_geosgeom_getcoordseq_data : public capitest::test_handlers {};
+struct test_geosgeom_getcoordseq_data : public capitest::utility {};
 
 typedef test_group<test_geosgeom_getcoordseq_data> group;
 typedef group::object object;
diff --git a/tests/unit/capi/GEOSGeom_getCoordinateDimensionTest.cpp b/tests/unit/capi/GEOSGeom_getCoordinateDimensionTest.cpp
index fa736e9..57c7e7f 100644
--- a/tests/unit/capi/GEOSGeom_getCoordinateDimensionTest.cpp
+++ b/tests/unit/capi/GEOSGeom_getCoordinateDimensionTest.cpp
@@ -9,7 +9,7 @@ namespace tut {
 // Test Group
 //
 
-struct test_geosgeom_getcoordinatedimension_data : public capitest::test_handlers {};
+struct test_geosgeom_getcoordinatedimension_data : public capitest::utility {};
 
 typedef test_group<test_geosgeom_getcoordinatedimension_data> group;
 typedef group::object object;
diff --git a/tests/unit/capi/GEOSGeom_getDimensionsTest.cpp b/tests/unit/capi/GEOSGeom_getDimensionsTest.cpp
index f03296a..79686b0 100644
--- a/tests/unit/capi/GEOSGeom_getDimensionsTest.cpp
+++ b/tests/unit/capi/GEOSGeom_getDimensionsTest.cpp
@@ -9,7 +9,7 @@ namespace tut {
 // Test Group
 //
 
-struct test_geosgeom_getdimensions_data : public capitest::test_handlers {};
+struct test_geosgeom_getdimensions_data : public capitest::utility {};
 
 typedef test_group<test_geosgeom_getdimensions_data> group;
 typedef group::object object;
diff --git a/tests/unit/capi/GEOSGeom_setPrecisionTest.cpp b/tests/unit/capi/GEOSGeom_setPrecisionTest.cpp
index 1f4998a..0f84e21 100644
--- a/tests/unit/capi/GEOSGeom_setPrecisionTest.cpp
+++ b/tests/unit/capi/GEOSGeom_setPrecisionTest.cpp
@@ -1,4 +1,3 @@
-#include <tut/tut.hpp>
 
 #include "capi_test_utils.h"
 
@@ -8,7 +7,7 @@ namespace tut {
 //
 
 // Common data used in test cases.
-struct test_capigeosgeomsetprecision_data : public capitest::test_handlers {
+struct test_capigeosgeomsetprecision_data : public capitest::utility {
 
     GEOSWKTWriter* wktw_;
     GEOSGeometry* geom1_;
@@ -75,7 +74,7 @@ void object::test<1>
 
     geom3_ = GEOSGeom_setPrecision(geom1_, 2.0, 0);
     ensure(geom3_ != 0);
-    ensure(capi_geometry_same(geom3_, "POLYGON EMPTY"));
+    ensure_geometry_equals(geom3_, "POLYGON EMPTY");
     ensure_equals(GEOSGeom_getPrecision(geom3_), 2.0);
 }
 
@@ -87,7 +86,7 @@ void object::test<2>
     geom1_ = fromWKT("LINESTRING(-3 6, 9 1)");
     geom3_ = GEOSGeom_setPrecision(geom1_, 2.0, 0);
     ensure(geom3_ != 0);
-    ensure(capi_geometry_same(geom3_, "LINESTRING (-2 6, 10 2)"));
+    ensure_geometry_equals(geom3_, "LINESTRING (-2 6, 10 2)");
 }
 
 // See effects of precision reduction on intersection operation
@@ -101,7 +100,7 @@ void object::test<3>
 
     geom3_ = GEOSIntersection(geom1_, geom2_);
     ensure(geom3_ != 0);
-    ensure(capi_geometry_same(geom3_, "POINT (3 20)"));
+    ensure_geometry_equals(geom3_, "POINT (3 20)");
 
     GEOSGeometry* g;
 
@@ -117,7 +116,7 @@ void object::test<3>
     GEOSGeom_destroy(geom3_);
     geom3_ = GEOSIntersection(geom1_, geom2_);
     ensure(geom3_ != 0);
-    ensure(capi_geometry_same(geom3_, "POINT (4 20)"));
+    ensure_geometry_equals(geom3_, "POINT (4 20)");
 
     // One input with precision grid of 0.5, the other of 2.0
     g = GEOSGeom_setPrecision(geom1_, 0.5, 0);
@@ -127,7 +126,7 @@ void object::test<3>
     GEOSGeom_destroy(geom3_);
     geom3_ = GEOSIntersection(geom1_, geom2_);
     ensure(geom3_ != 0);
-    ensure(capi_geometry_same(geom3_, "POINT (3 20)"));
+    ensure_geometry_equals(geom3_, "POINT (3 20)");
 
     ensure_equals(GEOSGeom_getPrecision(geom1_), 0.5);
     ensure_equals(GEOSGeom_getPrecision(geom2_), 2.0);
@@ -142,12 +141,12 @@ void object::test<4>
     geom1_ = fromWKT("POLYGON((10 10,20 10,16 15,20 20, 10 20, 14 15, 10 10))");
 
     geom2_ = GEOSGeom_setPrecision(geom1_, 5.0, 0);
-    ensure(capi_geometry_same(geom2_,
-        "MULTIPOLYGON (((10 10, 15 15, 20 10, 10 10)), ((15 15, 10 20, 20 20, 15 15)))"));
+    ensure_geometry_equals(geom2_,
+        "MULTIPOLYGON (((10 10, 15 15, 20 10, 10 10)), ((15 15, 10 20, 20 20, 15 15)))");
 
     geom3_ = GEOSGeom_setPrecision(geom1_, 5.0, GEOS_PREC_NO_TOPO);
-    ensure(capi_geometry_same(geom3_,
-        "POLYGON ((10 10, 20 10, 15 15, 20 20, 10 20, 15 15, 10 10))"));
+    ensure_geometry_equals(geom3_,
+        "POLYGON ((10 10, 20 10, 15 15, 20 20, 10 20, 15 15, 10 10))");
 }
 
 // Retain (or not) collapsed elements
@@ -159,7 +158,7 @@ void object::test<5>
     geom1_ = fromWKT("LINESTRING(1 0, 2 0)");
 
     geom2_ = GEOSGeom_setPrecision(geom1_, 5.0, 0);
-    ensure(capi_geometry_same(geom2_, "LINESTRING EMPTY"));
+    ensure_geometry_equals(geom2_, "LINESTRING EMPTY");
 
     geom3_ = GEOSGeom_setPrecision(geom1_, 5.0, GEOS_PREC_KEEP_COLLAPSED);
     ensure_equals(toWKT(geom3_), "LINESTRING (0 0, 0 0)");
diff --git a/tests/unit/capi/GEOSGetNumInteriorRingsTest.cpp b/tests/unit/capi/GEOSGetNumInteriorRingsTest.cpp
index ce9d96b..968868e 100644
--- a/tests/unit/capi/GEOSGetNumInteriorRingsTest.cpp
+++ b/tests/unit/capi/GEOSGetNumInteriorRingsTest.cpp
@@ -9,7 +9,7 @@ namespace tut {
 // Test Group
 //
 
-struct test_geosgetnuminteriorrings_data : public capitest::test_handlers {};
+struct test_geosgetnuminteriorrings_data : public capitest::utility {};
 
 typedef test_group<test_geosgetnuminteriorrings_data> group;
 typedef group::object object;
diff --git a/tests/unit/capi/GEOSIntersectionTest.cpp b/tests/unit/capi/GEOSIntersectionTest.cpp
index 9dcd61c..a919533 100644
--- a/tests/unit/capi/GEOSIntersectionTest.cpp
+++ b/tests/unit/capi/GEOSIntersectionTest.cpp
@@ -1,14 +1,8 @@
 //
 // Test Suite for C-API GEOSintersection
 
-#include <tut/tut.hpp>
+#include "capi_test_utils.h"
 
-// geos
-#include <geos_c.h>
-// std
-#include <cstdarg>
-#include <cstdio>
-#include <cstdlib>
 
 namespace tut {
 //
@@ -16,30 +10,18 @@ namespace tut {
 //
 
 // Common data used in test cases.
-struct test_capigeosintersection_data {
+struct test_capigeosintersection_data : public capitest::utility
+{
+
     GEOSWKTWriter* wktw_;
     GEOSGeometry* geom1_;
     GEOSGeometry* geom2_;
     GEOSGeometry* geom3_;
     GEOSGeometry* expected_;
 
-    static void
-    notice(const char* fmt, ...)
-    {
-        std::fprintf(stdout, "NOTICE: ");
-
-        va_list ap;
-        va_start(ap, fmt);
-        std::vfprintf(stdout, fmt, ap);
-        va_end(ap);
-
-        std::fprintf(stdout, "\n");
-    }
-
     test_capigeosintersection_data()
         : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr)
     {
-        initGEOS(notice, notice);
         wktw_ = GEOSWKTWriter_create();
         GEOSWKTWriter_setTrim(wktw_, 1);
         GEOSWKTWriter_setOutputDimension(wktw_, 3);
@@ -49,23 +31,6 @@ struct test_capigeosintersection_data {
         expected_ = nullptr;
     }
 
-    std::string
-    toWKT(GEOSGeometry* g)
-    {
-        char* wkt = GEOSWKTWriter_write(wktw_, g);
-        std::string ret(wkt);
-        GEOSFree(wkt);
-        return ret;
-    }
-
-    int
-    same(GEOSGeometry* g1, GEOSGeometry* g2, double tolerance)
-    {
-        GEOSNormalize(g1);
-        GEOSNormalize(g2);
-        return GEOSEqualsExact(g1, g2, tolerance);
-    }
-
     ~test_capigeosintersection_data()
     {
         GEOSWKTWriter_destroy(wktw_);
@@ -77,7 +42,6 @@ struct test_capigeosintersection_data {
         geom2_ = nullptr;
         geom3_ = nullptr;
         expected_ = nullptr;
-        finishGEOS();
     }
 
 };
@@ -104,7 +68,7 @@ void object::test<1>
 
     geom3_ = GEOSIntersection(geom1_, geom2_);
     ensure(nullptr != geom3_);
-    ensure_equals(toWKT(geom3_), std::string("POLYGON EMPTY"));
+    ensure_geometry_equals(geom3_, "POLYGON EMPTY");
 }
 
 template<>
@@ -120,7 +84,7 @@ void object::test<2>
 
     geom3_ = GEOSIntersection(geom1_, geom2_);
     ensure(nullptr != geom3_);
-    ensure_equals(toWKT(geom3_), std::string("POINT (2 2)"));
+    ensure_geometry_equals(geom3_, "POINT (2 2)");
 }
 
 template<>
@@ -138,7 +102,7 @@ void object::test<3>
     geom3_ = GEOSIntersection(geom1_, geom2_);
 
     ensure(nullptr != geom3_);
-    ensure(same(geom3_, expected_, 0.1));
+    ensure_geometry_equals(geom3_, expected_, 0.1);
 }
 
 /* See http://trac.osgeo.org/geos/ticket/719 */
diff --git a/tests/unit/capi/GEOSLengthTest.cpp b/tests/unit/capi/GEOSLengthTest.cpp
index 9214e76..a57033d 100644
--- a/tests/unit/capi/GEOSLengthTest.cpp
+++ b/tests/unit/capi/GEOSLengthTest.cpp
@@ -9,7 +9,7 @@ namespace tut {
 // Test Group
 //
 
-struct test_geoslength_data : public capitest::test_handlers {};
+struct test_geoslength_data : public capitest::utility {};
 
 typedef test_group<test_geoslength_data> group;
 typedef group::object object;
diff --git a/tests/unit/capi/GEOSSetSRIDTest.cpp b/tests/unit/capi/GEOSSetSRIDTest.cpp
index 13a7645..7dce47d 100644
--- a/tests/unit/capi/GEOSSetSRIDTest.cpp
+++ b/tests/unit/capi/GEOSSetSRIDTest.cpp
@@ -9,7 +9,7 @@ namespace tut {
 // Test Group
 //
 
-struct test_geossetsrid_data : public capitest::test_handlers {};
+struct test_geossetsrid_data : public capitest::utility {};
 
 typedef test_group<test_geossetsrid_data> group;
 typedef group::object object;
diff --git a/tests/unit/capi/GEOSUnionPrecTest.cpp b/tests/unit/capi/GEOSUnionPrecTest.cpp
index b5c2ab9..11cb581 100644
--- a/tests/unit/capi/GEOSUnionPrecTest.cpp
+++ b/tests/unit/capi/GEOSUnionPrecTest.cpp
@@ -9,7 +9,7 @@ namespace tut {
 // Test Group
 //
 
-struct test_geosunionprec_data : public capitest::test_handlers {};
+struct test_geosunionprec_data : public capitest::utility {};
 
 typedef test_group<test_geosunionprec_data> group;
 typedef group::object object;
diff --git a/tests/unit/capi/GEOSUnionTest.cpp b/tests/unit/capi/GEOSUnionTest.cpp
index ed962db..2efceb2 100644
--- a/tests/unit/capi/GEOSUnionTest.cpp
+++ b/tests/unit/capi/GEOSUnionTest.cpp
@@ -9,7 +9,7 @@ namespace tut {
 // Test Group
 //
 
-struct test_geosunion_data : public capitest::test_handlers {};
+struct test_geosunion_data : public capitest::utility {};
 
 typedef test_group<test_geosunion_data> group;
 typedef group::object object;
diff --git a/tests/unit/capi/GEOSisValidReasonTest.cpp b/tests/unit/capi/GEOSisValidReasonTest.cpp
index 4f4bfd7..8166cc5 100644
--- a/tests/unit/capi/GEOSisValidReasonTest.cpp
+++ b/tests/unit/capi/GEOSisValidReasonTest.cpp
@@ -9,7 +9,7 @@ namespace tut {
 // Test Group
 //
 
-struct test_geosisvalid_data : public capitest::test_handlers {};
+struct test_geosisvalid_data : public capitest::utility {};
 
 typedef test_group<test_geosisvalid_data> group;
 typedef group::object object;
diff --git a/tests/unit/capi/GEOSisValidTest.cpp b/tests/unit/capi/GEOSisValidTest.cpp
index b1aa68a..cf20091 100644
--- a/tests/unit/capi/GEOSisValidTest.cpp
+++ b/tests/unit/capi/GEOSisValidTest.cpp
@@ -9,7 +9,7 @@ namespace tut {
 // Test Group
 //
 
-struct test_geosisvalidreason_data : public capitest::test_handlers {};
+struct test_geosisvalidreason_data : public capitest::utility {};
 
 typedef test_group<test_geosisvalidreason_data> group;
 typedef group::object object;
diff --git a/tests/unit/capi/capi_test_utils.h b/tests/unit/capi/capi_test_utils.h
index a725c53..0f20a0b 100644
--- a/tests/unit/capi/capi_test_utils.h
+++ b/tests/unit/capi/capi_test_utils.h
@@ -1,6 +1,8 @@
 
 #pragma once
 
+#include <tut/tut.hpp>
+
 #include <geos_c.h>
 
 #include <cstdarg>
@@ -11,7 +13,18 @@
 
 namespace capitest {
 
-    struct test_handlers {
+    struct utility {
+
+        utility()
+        {
+            initGEOS(notice, notice);
+        }
+
+        ~utility()
+        {
+            finishGEOS();
+        }
+
         static void notice(const char* fmt, ...)
         {
             std::fprintf(stdout, "NOTICE: ");
@@ -24,39 +37,50 @@ namespace capitest {
             std::fprintf(stdout, "\n");
         }
 
-        bool
-        capi_geometry_same(GEOSGeometry* g1, GEOSGeometry* g2, double tolerance)
+        void
+        ensure_geometry_equals(GEOSGeometry* g1, GEOSGeometry* g2, double tolerance)
         {
             GEOSNormalize(g1);
             GEOSNormalize(g2);
-            return GEOSEqualsExact(g1, g2, tolerance);
+            bool rslt = GEOSEqualsExact(g1, g2, tolerance);
+            if (!rslt)
+            {
+                char* wkt1 = GEOSGeomToWKT(g1);
+                char* wkt2 = GEOSGeomToWKT(g2);
+                std::fprintf(stdout, "\n%s != %s\n", wkt1, wkt2);
+                GEOSFree(wkt1);
+                GEOSFree(wkt2);
+            }
+            tut::ensure_equals("GEOSEqualsExact(g1, g2, tolerance)", rslt, 1);
+            return;
         }
 
-        bool
-        capi_geometry_same(GEOSGeometry* g1, GEOSGeometry* g2)
+        void
+        ensure_geometry_equals(GEOSGeometry* g1, GEOSGeometry* g2)
         {
-            return capi_geometry_same(g1, g2, 1e-12);
+            return ensure_geometry_equals(g1, g2, 1e-12);
         }
 
-        bool
-        capi_geometry_same(GEOSGeometry* g1, const char* g2str)
+        void
+        ensure_geometry_equals(GEOSGeometry* g1, const char* g2str)
         {
             GEOSGeometry* g2 = GEOSGeomFromWKT(g2str);
             tut::ensure(g2 != 0);
-            bool rslt = capi_geometry_same(g1, g2);
-            GEOSGeom_destroy(g2);
-            return rslt;
-        }
-
-        test_handlers()
-        {
-            initGEOS(notice, notice);
+            GEOSNormalize(g1);
+            GEOSNormalize(g2);
+            bool rslt = GEOSEqualsExact(g1, g2, 1e-12);
+            if (!rslt)
+            {
+                char* wkt1 = GEOSGeomToWKT(g1);
+                char* wkt2 = GEOSGeomToWKT(g2);
+                std::fprintf(stdout, "\n%s != %s\n", wkt1, wkt2);
+                GEOSFree(wkt1);
+                GEOSFree(wkt2);
+            }
+            tut::ensure_equals("GEOSEqualsExact(g1, g2, 1e-12)", rslt, 1);
+            return;
         }
 
-        ~test_handlers()
-        {
-            finishGEOS();
-        }
     };
 
 }

-----------------------------------------------------------------------

Summary of changes:
 tests/unit/capi/GEOSBoundaryTest.cpp               |  2 +-
 tests/unit/capi/GEOSEnvelopeTest.cpp               |  2 +-
 tests/unit/capi/GEOSGeomFromWKBTest.cpp            |  2 +-
 tests/unit/capi/GEOSGeom_createLineStringTest.cpp  |  2 +-
 tests/unit/capi/GEOSGeom_getCoordSeqTest.cpp       |  2 +-
 .../capi/GEOSGeom_getCoordinateDimensionTest.cpp   |  2 +-
 tests/unit/capi/GEOSGeom_getDimensionsTest.cpp     |  2 +-
 tests/unit/capi/GEOSGeom_setPrecisionTest.cpp      | 23 ++++----
 tests/unit/capi/GEOSGetNumInteriorRingsTest.cpp    |  2 +-
 tests/unit/capi/GEOSIntersectionTest.cpp           | 50 +++-------------
 tests/unit/capi/GEOSLengthTest.cpp                 |  2 +-
 tests/unit/capi/GEOSSetSRIDTest.cpp                |  2 +-
 tests/unit/capi/GEOSUnionPrecTest.cpp              |  2 +-
 tests/unit/capi/GEOSUnionTest.cpp                  |  2 +-
 tests/unit/capi/GEOSisValidReasonTest.cpp          |  2 +-
 tests/unit/capi/GEOSisValidTest.cpp                |  2 +-
 tests/unit/capi/capi_test_utils.h                  | 66 +++++++++++++++-------
 17 files changed, 77 insertions(+), 90 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list