[geos-commits] [SCM] GEOS branch main updated. 5e5fc99c7a3d97b12fe76ca43b940abc79f8d389

git at osgeo.org git at osgeo.org
Tue May 21 11:30:15 PDT 2024


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, main has been updated
       via  5e5fc99c7a3d97b12fe76ca43b940abc79f8d389 (commit)
      from  6043951eef998c8174e5d618bf9e0418601f1e06 (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 5e5fc99c7a3d97b12fe76ca43b940abc79f8d389
Author: Sandro Santilli <strk at kbt.io>
Date:   Tue May 21 20:27:31 2024 +0200

    Drop duplicated code in GEOSGeom_createTest and GEOSOrientationIndexTest
    
    Closes GA-1098

diff --git a/tests/unit/capi/GEOSGeom_createTest.cpp b/tests/unit/capi/GEOSGeom_createTest.cpp
index 6910a74f7..6bfb82c69 100644
--- a/tests/unit/capi/GEOSGeom_createTest.cpp
+++ b/tests/unit/capi/GEOSGeom_createTest.cpp
@@ -22,23 +22,9 @@ namespace tut {
 struct test_capigeosgeom_create_data  : public capitest::utility
 {
     GEOSGeometry* geom1_;
-    GEOSContextHandle_t handle_;
-
-    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_capigeosgeom_create_data()
-        : geom1_(nullptr), handle_(initGEOS_r(notice, notice))
+        : geom1_(nullptr)
     {
     }
 
@@ -46,7 +32,6 @@ struct test_capigeosgeom_create_data  : public capitest::utility
     {
         GEOSGeom_destroy(geom1_);
         geom1_ = nullptr;
-        finishGEOS_r(handle_);
     }
 
 };
@@ -66,12 +51,12 @@ template<>
 void object::test<1>
 ()
 {
-    geom1_ = GEOSGeom_createEmptyPoint_r(handle_);
-    ensure(0 != GEOSisEmpty_r(handle_, geom1_));
-    ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_POINT);
+    geom1_ = GEOSGeom_createEmptyPoint();
+    ensure(0 != GEOSisEmpty(geom1_));
+    ensure_equals(GEOSGeomTypeId(geom1_), GEOS_POINT);
 
-    ensure_equals(GEOSHasZ_r(handle_, geom1_), 0);
-    ensure_equals(GEOSHasM_r(handle_, geom1_), 0);
+    ensure_equals(GEOSHasZ(geom1_), 0);
+    ensure_equals(GEOSHasM(geom1_), 0);
 
     GEOSGeom_destroy(geom1_);
     geom1_ = nullptr;
@@ -83,12 +68,12 @@ template<>
 void object::test<2>
 ()
 {
-    geom1_ = GEOSGeom_createEmptyLineString_r(handle_);
-    ensure(0 != GEOSisEmpty_r(handle_, geom1_));
-    ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_LINESTRING);
+    geom1_ = GEOSGeom_createEmptyLineString();
+    ensure(0 != GEOSisEmpty(geom1_));
+    ensure_equals(GEOSGeomTypeId(geom1_), GEOS_LINESTRING);
 
-    ensure_equals(GEOSHasZ_r(handle_, geom1_), 0);
-    ensure_equals(GEOSHasM_r(handle_, geom1_), 0);
+    ensure_equals(GEOSHasZ(geom1_), 0);
+    ensure_equals(GEOSHasM(geom1_), 0);
 
     GEOSGeom_destroy(geom1_);
     geom1_ = nullptr;
@@ -101,12 +86,12 @@ template<>
 void object::test<3>
 ()
 {
-    geom1_ = GEOSGeom_createEmptyPolygon_r(handle_);
-    ensure(0 != GEOSisEmpty_r(handle_, geom1_));
-    ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_POLYGON);
+    geom1_ = GEOSGeom_createEmptyPolygon();
+    ensure(0 != GEOSisEmpty(geom1_));
+    ensure_equals(GEOSGeomTypeId(geom1_), GEOS_POLYGON);
 
-    ensure_equals(GEOSHasZ_r(handle_, geom1_), 0);
-    ensure_equals(GEOSHasM_r(handle_, geom1_), 0);
+    ensure_equals(GEOSHasZ(geom1_), 0);
+    ensure_equals(GEOSHasM(geom1_), 0);
 
     GEOSGeom_destroy(geom1_);
     geom1_ = nullptr;
@@ -118,12 +103,12 @@ template<>
 void object::test<4>
 ()
 {
-    geom1_ = GEOSGeom_createEmptyCollection_r(handle_, GEOS_MULTIPOINT);
-    ensure(0 != GEOSisEmpty_r(handle_, geom1_));
-    ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_MULTIPOINT);
+    geom1_ = GEOSGeom_createEmptyCollection(GEOS_MULTIPOINT);
+    ensure(0 != GEOSisEmpty(geom1_));
+    ensure_equals(GEOSGeomTypeId(geom1_), GEOS_MULTIPOINT);
 
-    ensure_equals(GEOSHasZ_r(handle_, geom1_), 0);
-    ensure_equals(GEOSHasM_r(handle_, geom1_), 0);
+    ensure_equals(GEOSHasZ(geom1_), 0);
+    ensure_equals(GEOSHasM(geom1_), 0);
 
     GEOSGeom_destroy(geom1_);
     geom1_ = nullptr;
@@ -135,12 +120,12 @@ template<>
 void object::test<5>
 ()
 {
-    geom1_ = GEOSGeom_createEmptyCollection_r(handle_, GEOS_MULTILINESTRING);
-    ensure(0 != GEOSisEmpty_r(handle_, geom1_));
-    ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_MULTILINESTRING);
+    geom1_ = GEOSGeom_createEmptyCollection(GEOS_MULTILINESTRING);
+    ensure(0 != GEOSisEmpty(geom1_));
+    ensure_equals(GEOSGeomTypeId(geom1_), GEOS_MULTILINESTRING);
 
-    ensure_equals(GEOSHasZ_r(handle_, geom1_), 0);
-    ensure_equals(GEOSHasM_r(handle_, geom1_), 0);
+    ensure_equals(GEOSHasZ(geom1_), 0);
+    ensure_equals(GEOSHasM(geom1_), 0);
 
     GEOSGeom_destroy(geom1_);
     geom1_ = nullptr;
@@ -152,12 +137,12 @@ template<>
 void object::test<6>
 ()
 {
-    geom1_ = GEOSGeom_createEmptyCollection_r(handle_, GEOS_MULTIPOLYGON);
-    ensure(0 != GEOSisEmpty_r(handle_, geom1_));
-    ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_MULTIPOLYGON);
+    geom1_ = GEOSGeom_createEmptyCollection(GEOS_MULTIPOLYGON);
+    ensure(0 != GEOSisEmpty(geom1_));
+    ensure_equals(GEOSGeomTypeId(geom1_), GEOS_MULTIPOLYGON);
 
-    ensure_equals(GEOSHasZ_r(handle_, geom1_), 0);
-    ensure_equals(GEOSHasM_r(handle_, geom1_), 0);
+    ensure_equals(GEOSHasZ(geom1_), 0);
+    ensure_equals(GEOSHasM(geom1_), 0);
 
     GEOSGeom_destroy(geom1_);
     geom1_ = nullptr;
@@ -169,12 +154,12 @@ template<>
 void object::test<7>
 ()
 {
-    geom1_ = GEOSGeom_createEmptyCollection_r(handle_, GEOS_GEOMETRYCOLLECTION);
-    ensure(0 != GEOSisEmpty_r(handle_, geom1_));
-    ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_GEOMETRYCOLLECTION);
+    geom1_ = GEOSGeom_createEmptyCollection(GEOS_GEOMETRYCOLLECTION);
+    ensure(0 != GEOSisEmpty(geom1_));
+    ensure_equals(GEOSGeomTypeId(geom1_), GEOS_GEOMETRYCOLLECTION);
 
-    ensure_equals(GEOSHasZ_r(handle_, geom1_), 0);
-    ensure_equals(GEOSHasM_r(handle_, geom1_), 0);
+    ensure_equals(GEOSHasZ(geom1_), 0);
+    ensure_equals(GEOSHasM(geom1_), 0);
 
     GEOSGeom_destroy(geom1_);
     geom1_ = nullptr;
diff --git a/tests/unit/capi/GEOSOrientationIndexTest.cpp b/tests/unit/capi/GEOSOrientationIndexTest.cpp
index 5a229391c..71e50d6f8 100644
--- a/tests/unit/capi/GEOSOrientationIndexTest.cpp
+++ b/tests/unit/capi/GEOSOrientationIndexTest.cpp
@@ -11,39 +11,15 @@
 #include <cstdlib>
 #include <memory>
 
+#include "capi_test_utils.h"
+
 namespace tut {
 //
 // Test Group
 //
 
 // Common data used in test cases.
-struct test_capigeosorientationindex_data {
-    GEOSContextHandle_t handle_;
-
-    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_capigeosorientationindex_data()
-        : handle_(initGEOS_r(notice, notice))
-    {
-    }
-
-    ~test_capigeosorientationindex_data()
-    {
-        finishGEOS_r(handle_);
-    }
-
-};
+struct test_capigeosorientationindex_data : public capitest::utility {};
 
 typedef test_group<test_capigeosorientationindex_data> group;
 typedef group::object object;
@@ -60,7 +36,7 @@ template<>
 void object::test<1>
 ()
 {
-    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, 5, 0);
+    int ret = GEOSOrientationIndex(0, 0, 10, 0, 5, 0);
     ensure_equals(ret, 0);
 }
 
@@ -70,7 +46,7 @@ template<>
 void object::test<2>
 ()
 {
-    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, 10, 0);
+    int ret = GEOSOrientationIndex(0, 0, 10, 0, 10, 0);
     ensure_equals(ret, 0);
 }
 
@@ -80,7 +56,7 @@ template<>
 void object::test<3>
 ()
 {
-    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, 0, 0);
+    int ret = GEOSOrientationIndex(0, 0, 10, 0, 0, 0);
     ensure_equals(ret, 0);
 }
 
@@ -90,7 +66,7 @@ template<>
 void object::test<4>
 ()
 {
-    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, -5, 0);
+    int ret = GEOSOrientationIndex(0, 0, 10, 0, -5, 0);
     ensure_equals(ret, 0);
 }
 
@@ -100,7 +76,7 @@ template<>
 void object::test<5>
 ()
 {
-    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, 20, 0);
+    int ret = GEOSOrientationIndex(0, 0, 10, 0, 20, 0);
     ensure_equals(ret, 0);
 }
 
@@ -110,7 +86,7 @@ template<>
 void object::test<6>
 ()
 {
-    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 5, 6);
+    int ret = GEOSOrientationIndex(0, 0, 10, 10, 5, 6);
     ensure_equals(ret, 1);
 }
 
@@ -120,7 +96,7 @@ template<>
 void object::test<7>
 ()
 {
-    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 5, 20);
+    int ret = GEOSOrientationIndex(0, 0, 10, 10, 5, 20);
     ensure_equals(ret, 1);
 }
 
@@ -130,7 +106,7 @@ template<>
 void object::test<8>
 ()
 {
-    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 5, 3);
+    int ret = GEOSOrientationIndex(0, 0, 10, 10, 5, 3);
     ensure_equals(ret, -1);
 }
 
@@ -140,7 +116,7 @@ template<>
 void object::test<9>
 ()
 {
-    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 5, -2);
+    int ret = GEOSOrientationIndex(0, 0, 10, 10, 5, -2);
     ensure_equals(ret, -1);
 }
 
@@ -150,7 +126,7 @@ template<>
 void object::test<10>
 ()
 {
-    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 1000000, 1000001);
+    int ret = GEOSOrientationIndex(0, 0, 10, 10, 1000000, 1000001);
     ensure_equals(ret, 1);
 }
 
@@ -160,7 +136,7 @@ template<>
 void object::test<11>
 ()
 {
-    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 1000000,  999999);
+    int ret = GEOSOrientationIndex(0, 0, 10, 10, 1000000,  999999);
     ensure_equals(ret, -1);
 }
 

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

Summary of changes:
 tests/unit/capi/GEOSGeom_createTest.cpp      | 87 ++++++++++++----------------
 tests/unit/capi/GEOSOrientationIndexTest.cpp | 52 +++++------------
 2 files changed, 50 insertions(+), 89 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list