[geos-commits] [SCM] GEOS branch main updated. cfad2ab8f338045d0862dde9f205eca0bdc99f32

git at osgeo.org git at osgeo.org
Mon Nov 20 10:51:41 PST 2023


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  cfad2ab8f338045d0862dde9f205eca0bdc99f32 (commit)
      from  b3c6777b99fdec10a4cbdf26005697df0111f67d (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 cfad2ab8f338045d0862dde9f205eca0bdc99f32
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Mon Nov 20 10:50:53 2023 -0800

    Clean up CAPI tests to use the CAPI helper headers more and be a little more terse.

diff --git a/tests/unit/capi/GEOSEqualsTest.cpp b/tests/unit/capi/GEOSEqualsTest.cpp
index bc9cad63a..793207f49 100644
--- a/tests/unit/capi/GEOSEqualsTest.cpp
+++ b/tests/unit/capi/GEOSEqualsTest.cpp
@@ -35,19 +35,11 @@ template<>
 void object::test<1>
 ()
 {
-    geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
-    geom2_ = GEOSGeomFromWKT("POLYGON EMPTY");
+    geom1_ = fromWKT("POLYGON EMPTY");
+    geom2_ = fromWKT("POLYGON EMPTY");
 
-    ensure(nullptr != geom1_);
-    ensure(nullptr != geom2_);
-
-    char const r1 = GEOSEquals(geom1_, geom2_);
-
-    ensure_equals(r1, 1);
-
-    char const r2 = GEOSEquals(geom2_, geom1_);
-
-    ensure_equals(r2, 1);
+    ensure_equals(GEOSEquals(geom1_, geom2_), 1);
+    ensure_equals(GEOSEquals(geom2_, geom1_), 1);
 }
 
 template<>
@@ -55,18 +47,13 @@ template<>
 void object::test<2>
 ()
 {
-    geom1_ = GEOSGeomFromWKT("POINT(2 3)");
-    geom2_ = GEOSGeomFromWKT("POINT(2 2)");
-
-    ensure(nullptr != geom1_);
-    ensure(nullptr != geom2_);
+    geom1_ = fromWKT("POINT(2 3)");
+    geom2_ = fromWKT("POINT(2 2)");
 
     char const r1 = GEOSEquals(geom1_, geom2_);
-
     ensure_equals(int(r1), 0);
 
     char const r2 = GEOSEquals(geom2_, geom1_);
-
     ensure_equals(int(r2), 0);
 }
 
@@ -75,18 +62,13 @@ template<>
 void object::test<3>
 ()
 {
-    geom1_ = GEOSGeomFromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))");
-    geom2_ = GEOSGeomFromWKT("POLYGON((0 0,0 10,10 10,10 0,0 0))");
-
-    ensure(nullptr != geom1_);
-    ensure(nullptr != geom2_);
+    geom1_ = fromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))");
+    geom2_ = fromWKT("POLYGON((0 0,0 10,10 10,10 0,0 0))");
 
     char const r1 = GEOSEquals(geom1_, geom2_);
-
     ensure_equals(int(r1), 1);
 
     char const r2 = GEOSEquals(geom2_, geom1_);
-
     ensure_equals(int(r2), 1);
 }
 
@@ -111,9 +93,7 @@ void object::test<4>
                                     nullptr, 0);
 
     char const r1 = GEOSEquals(geom1_, geom1_);
-
     ensure_equals(int(r1), 2);
-
 }
 
 // This is a test for bug #357 (GEOSEquals with inf coords)
@@ -126,17 +106,16 @@ void object::test<5>
         "0103000020E61000000100000005000000737979F3DDCC2CC0F92154F9E7534540000000000000F07F000000000000F07F8F806E993F7E55C0304B29FFEA8554400634E8D1DD424540B5FEE6A37FCD4540737979F3DDCC2CC0F92154F9E7534540";
 
     geom1_ = GEOSGeomFromHEX_buf((unsigned char*)hex, std::strlen(hex));
-
     ensure(nullptr != geom1_);
 
     char const r1 = GEOSEquals(geom1_, geom1_);
-
     ensure_equals(int(r1), 2);
-
 }
 
-#if 0 // fails
-// This is a test for bug #752 (GEOSEquals with collection)
+#if 0
+// FAILS
+// https://trac.osgeo.org/geos/ticket/752
+// GEOSEquals with collection inputs
 template<>
 template<>
 void object::test<6>
@@ -147,12 +126,9 @@ void object::test<6>
                        "POLYGON ((3 3, 3 4, 4 4, 4 3, 3 3))"
                        ")";
 
-    geom1_ = GEOSGeomFromWKT(wkt1);
-
-    ensure(0 != geom1_);
+    geom1_ = fromWKT(wkt1);
 
     char const r1 = GEOSEquals(geom1_, geom1_);
-
     ensure_equals(int(r1), 1);
 }
 #endif
diff --git a/tests/unit/capi/GEOSFrechetDistanceTest.cpp b/tests/unit/capi/GEOSFrechetDistanceTest.cpp
index ab79a48ac..93c0f657e 100644
--- a/tests/unit/capi/GEOSFrechetDistanceTest.cpp
+++ b/tests/unit/capi/GEOSFrechetDistanceTest.cpp
@@ -19,10 +19,7 @@ namespace tut {
 //
 
 // Common data used in test cases.
-struct test_capigeosfrechetdistance_data : public capitest::utility {
-    test_capigeosfrechetdistance_data() {
-    }
-};
+struct test_capigeosfrechetdistance_data : public capitest::utility {};
 
 typedef test_group<test_capigeosfrechetdistance_data> group;
 typedef group::object object;
@@ -38,8 +35,8 @@ template<>
 void object::test<1>
 ()
 {
-    geom1_ = GEOSGeomFromWKT("LINESTRING (0 0, 100 0)");
-    geom2_ = GEOSGeomFromWKT("LINESTRING (0 0, 50 50, 100 0)");
+    geom1_ = fromWKT("LINESTRING (0 0, 100 0)");
+    geom2_ = fromWKT("LINESTRING (0 0, 50 50, 100 0)");
 
     double dist;
     int ret = GEOSFrechetDistance(geom1_, geom2_, &dist);
@@ -53,8 +50,8 @@ template<>
 void object::test<2>
 ()
 {
-    geom1_ = GEOSGeomFromWKT("LINESTRING (0 0, 100 0)");
-    geom2_ = GEOSGeomFromWKT("LINESTRING (0 0, 50 50, 100 0)");
+    geom1_ = fromWKT("LINESTRING (0 0, 100 0)");
+    geom2_ = fromWKT("LINESTRING (0 0, 50 50, 100 0)");
 
     double dist;
     int ret = GEOSFrechetDistanceDensify(geom1_, geom2_, 0.5, &dist);
@@ -70,13 +67,13 @@ template<>
 void object::test<3>
 ()
 {
-    geom1_ = GEOSGeomFromWKT("LINESTRING (0 0, 3 7, 5 5)");
-    geom2_ = GEOSGeomFromWKT("LINESTRING (0 0, 9 1, 2 2)");
+    geom1_ = fromWKT("LINESTRING (0 0, 3 7, 5 5)");
+    geom2_ = fromWKT("LINESTRING (0 0, 9 1, 2 2)");
 
-    double dist;
+    double dist = 0;
     GEOSFrechetDistanceDensify(geom1_, geom2_, 1e-40, &dist);
 
-    // no crash
+    ensure(dist >= 0); // no crash
 }
 
 // No crash with tiny densify fraction
@@ -86,13 +83,13 @@ template<>
 void object::test<4>
 ()
 {
-    geom1_ = GEOSGeomFromWKT("LINESTRING (0 0, 3 7, 5 5)");
-    geom2_ = GEOSGeomFromWKT("LINESTRING (0 0, 9 1, 2 2)");
+    geom1_ = fromWKT("LINESTRING (0 0, 3 7, 5 5)");
+    geom2_ = fromWKT("LINESTRING (0 0, 9 1, 2 2)");
 
-    double dist;
+    double dist = 0;
     GEOSFrechetDistanceDensify(geom1_, geom2_, 1e-19, &dist);
 
-    // no crash
+    ensure(dist >= 0); // no crash
 }
 
 } // namespace tut
diff --git a/tests/unit/capi/GEOSGeom_createCollectionTest.cpp b/tests/unit/capi/GEOSGeom_createCollectionTest.cpp
index da1d355c4..c0ac20ce7 100644
--- a/tests/unit/capi/GEOSGeom_createCollectionTest.cpp
+++ b/tests/unit/capi/GEOSGeom_createCollectionTest.cpp
@@ -13,62 +13,33 @@
 #include <string>
 #include <vector>
 
+#include "capi_test_utils.h"
+
 namespace tut {
 //
 // Test Group
 //
 
 // Common data used in test cases.
-struct test_capigeosgeom_createcollection_data {
-    GEOSContextHandle_t handle_;
-    GEOSWKTReader * reader_;
-    GEOSGeometry * geom_;
-    GEOSGeometry ** geoms_;
-    unsigned int ngeoms_;
-
-    enum { geom_size = 3 };
-
-    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");
-    }
-
-    GEOSGeometry*
-    read(const char* wkt)
-    {
-        return GEOSWKTReader_read_r(handle_, reader_, wkt);
-    }
+struct test_capigeosgeom_createcollection_data : public capitest::utility
+{
+    GEOSGeometry ** m_geoms;
+    unsigned int m_ngeoms;
 
     test_capigeosgeom_createcollection_data()
-        : handle_(initGEOS_r(notice, notice))
-        , reader_(GEOSWKTReader_create_r(handle_))
-        , geom_(nullptr)
-        , geoms_(nullptr)
-        , ngeoms_(0)
-    {
-    }
+        : m_geoms(nullptr)
+        , m_ngeoms(0)
+    {}
 
     ~test_capigeosgeom_createcollection_data()
     {
-        if (reader_) GEOSWKTReader_destroy_r(handle_, reader_);
-        if (geom_)   GEOSGeom_destroy_r(handle_, geom_);
-        if (geoms_)  GEOSFree_r(handle_, geoms_);
-        finishGEOS_r(handle_);
-        handle_ = nullptr;
-        reader_ = nullptr;
-        geom_ = nullptr;
-        geoms_ = nullptr;
+        if (m_geoms) GEOSFree(m_geoms);
+        m_geoms = nullptr;
     }
 };
 
+#define geom_size 3
+
 typedef test_group<test_capigeosgeom_createcollection_data> group;
 typedef group::object object;
 
@@ -81,83 +52,87 @@ group test_capigeosgeom_createcollection_group("capi::GEOSGeom_createCollection"
 // Create collection from constant length C-array
 template<>
 template<>
-void object::test<1>
-()
+void object::test<1>()
 {
-    GEOSGeom geoms[geom_size];
-    geoms[0] = GEOSGeom_createEmptyPoint_r(handle_);
-    geoms[1] = GEOSGeom_createEmptyPoint_r(handle_);
-    geoms[2] = GEOSGeom_createEmptyPoint_r(handle_);
+    GEOSGeometry* geoms[geom_size];
+    geoms[0] = GEOSGeom_createEmptyPoint();
+    geoms[1] = GEOSGeom_createEmptyPoint();
+    geoms[2] = GEOSGeom_createEmptyPoint();
+
     // takes ownership of individual geometries
-    geom_ = GEOSGeom_createCollection_r(handle_, GEOS_MULTIPOINT, geoms, geom_size);
-    ensure_equals(GEOSGetNumGeometries_r(handle_, geom_), (int)geom_size);
+    geom1_ = GEOSGeom_createCollection(GEOS_MULTIPOINT, geoms, geom_size);
+    ensure_equals(GEOSGetNumGeometries(geom1_), geom_size);
 }
 
 // Create collection from constant length std::array
 template<>
 template<>
-void object::test<2>
-()
+void object::test<2>()
 {
-    std::array<GEOSGeom, geom_size> geoms = {{
-        GEOSGeom_createEmptyLineString_r(handle_),
-        GEOSGeom_createEmptyLineString_r(handle_),
-        GEOSGeom_createEmptyLineString_r(handle_)
+    std::array<GEOSGeometry*, geom_size> geoms = {{
+        GEOSGeom_createEmptyLineString(),
+        GEOSGeom_createEmptyLineString(),
+        GEOSGeom_createEmptyLineString()
     }};
+
     // takes ownership of individual geometries
-    geom_ = GEOSGeom_createCollection_r(handle_, GEOS_MULTILINESTRING,
-                                        geoms.data(), static_cast<unsigned int>(geoms.size()));
-    ensure_equals(GEOSGetNumGeometries_r(handle_, geom_), geom_size);
+    geom1_ = GEOSGeom_createCollection(
+        GEOS_MULTILINESTRING,
+        geoms.data(),
+        static_cast<unsigned int>(geoms.size()));
+
+    ensure_equals(GEOSGetNumGeometries(geom1_), geom_size);
 }
 
 // Create collection from dynamic length std::vector of geometries
 template<>
 template<>
-void object::test<3>
-()
+void object::test<3>()
 {
-    std::vector<GEOSGeom> geoms;
-    geoms.push_back(GEOSGeom_createEmptyPolygon_r(handle_));
-    geoms.push_back(GEOSGeom_createEmptyPolygon_r(handle_));
-    geoms.push_back(GEOSGeom_createEmptyPolygon_r(handle_));
-    geoms.push_back(GEOSGeom_createEmptyPolygon_r(handle_));
-    geoms.push_back(GEOSGeom_createEmptyPolygon_r(handle_));
+    std::vector<GEOSGeometry*> geoms;
+    geoms.push_back(GEOSGeom_createEmptyPolygon());
+    geoms.push_back(GEOSGeom_createEmptyPolygon());
+    geoms.push_back(GEOSGeom_createEmptyPolygon());
+    geoms.push_back(GEOSGeom_createEmptyPolygon());
+    geoms.push_back(GEOSGeom_createEmptyPolygon());
+
     // takes ownership of individual geometries
-    geom_ = GEOSGeom_createCollection_r(handle_, GEOS_MULTIPOLYGON,
-                                        geoms.data(), static_cast<unsigned int>(geoms.size()));
-    ensure_equals(static_cast<size_t>(GEOSGetNumGeometries_r(handle_, geom_)), geoms.size());
+    geom1_ = GEOSGeom_createCollection(
+        GEOS_MULTIPOLYGON,
+        geoms.data(),
+        static_cast<unsigned int>(geoms.size()));
+
+    ensure_equals(static_cast<size_t>(GEOSGetNumGeometries(geom1_)), geoms.size());
 }
 
 // Error on invalid collection type, ownership is still transferred
 template<>
 template<>
-void object::test<4>
-()
+void object::test<4>()
 {
-    std::vector<GEOSGeom> geoms;
-    geoms.push_back(GEOSGeom_createEmptyPolygon_r(handle_));
+    std::vector<GEOSGeometry*> geoms;
+    geoms.push_back(GEOSGeom_createEmptyPolygon());
     // takes ownership of individual geometries
-    geom_ = GEOSGeom_createCollection_r(handle_, 12345,
-                                        geoms.data(), static_cast<unsigned int>(geoms.size()));
-    ensure(geom_ == nullptr);
+    geom1_ = GEOSGeom_createCollection(
+        12345,
+        geoms.data(),
+        static_cast<unsigned int>(geoms.size()));
+    ensure(geom1_ == nullptr);
 
-    geom_ = GEOSGeom_createEmptyCollection_r(handle_, 12345);
-    ensure(geom_ == nullptr);
+    geom1_ = GEOSGeom_createEmptyCollection(12345);
+    ensure(geom1_ == nullptr);
 }
 
 // Release empty collection
 template<>
 template<>
-void object::test<5>
-()
+void object::test<5>()
 {
-    const char *wkt = "MULTIPOLYGON EMPTY";
-    geom_ = read(wkt);
-    ensure(geom_ != nullptr);
+    geom1_ = fromWKT("MULTIPOLYGON EMPTY");
 
-    geoms_ = GEOSGeom_releaseCollection_r(handle_, geom_, &ngeoms_);
-    ensure(geoms_ == nullptr);
-    ensure(ngeoms_ == 0);
+    m_geoms = GEOSGeom_releaseCollection(geom1_, &m_ngeoms);
+    ensure(m_geoms == nullptr);
+    ensure(m_ngeoms == 0);
 }
 
 
@@ -167,19 +142,16 @@ template<>
 void object::test<6>
 ()
 {
-    const char *wkt = "GEOMETRYCOLLECTION(POINT(0 0), POINT(1 1))";
-    geom_ = read(wkt);
-    ensure(geom_ != nullptr);
+    geom1_ = fromWKT("GEOMETRYCOLLECTION(POINT(0 0), POINT(1 1))");
 
-    geoms_ = GEOSGeom_releaseCollection_r(handle_, geom_, &ngeoms_);
-    ensure(geoms_ != nullptr);
-    ensure(ngeoms_ == 2);
+    m_geoms = GEOSGeom_releaseCollection(geom1_, &m_ngeoms);
+    ensure(m_geoms != nullptr);
+    ensure(m_ngeoms == 2);
 
-    for (size_t i = 0 ; i < ngeoms_; i++) {
-        ensure(GEOSGeomTypeId_r(handle_, geoms_[i]) == GEOS_POINT);
-        GEOSGeom_destroy_r(handle_, geoms_[i]);
+    for (size_t i = 0 ; i < m_ngeoms; i++) {
+        ensure(GEOSGeomTypeId(m_geoms[i]) == GEOS_POINT);
+        GEOSGeom_destroy(m_geoms[i]);
     }
-
 }
 
 // Release typed collection
@@ -188,19 +160,16 @@ template<>
 void object::test<7>
 ()
 {
-    const char *wkt = "MULTIPOINT((0 0), (1 1))";
-    geom_ = read(wkt);
-    ensure(geom_ != nullptr);
+    geom1_ = fromWKT("MULTIPOINT((0 0), (1 1))");
 
-    geoms_ = GEOSGeom_releaseCollection_r(handle_, geom_, &ngeoms_);
-    ensure(geoms_ != nullptr);
-    ensure(ngeoms_ == 2);
+    m_geoms = GEOSGeom_releaseCollection(geom1_, &m_ngeoms);
+    ensure(m_geoms != nullptr);
+    ensure(m_ngeoms == 2);
 
-    for (size_t i = 0 ; i < ngeoms_; i++) {
-        ensure(GEOSGeomTypeId_r(handle_, geoms_[i]) == GEOS_POINT);
-        GEOSGeom_destroy_r(handle_, geoms_[i]);
+    for (size_t i = 0 ; i < m_ngeoms; i++) {
+        ensure(GEOSGeomTypeId(m_geoms[i]) == GEOS_POINT);
+        GEOSGeom_destroy(m_geoms[i]);
     }
-
 }
 
 } // namespace tut
diff --git a/tests/unit/capi/GEOSGeom_createLineStringTest.cpp b/tests/unit/capi/GEOSGeom_createLineStringTest.cpp
index c9f6148dc..258ac7629 100644
--- a/tests/unit/capi/GEOSGeom_createLineStringTest.cpp
+++ b/tests/unit/capi/GEOSGeom_createLineStringTest.cpp
@@ -19,18 +19,14 @@ void object::test<1>
 ()
 {
     GEOSCoordSequence* seq = GEOSCoordSeq_create(3, 2);
-
     GEOSCoordSeq_setXY(seq, 0, 1, 2);
     GEOSCoordSeq_setXY(seq, 1, 4, 5);
     GEOSCoordSeq_setXY(seq, 2, 9, -2);
 
-    GEOSGeometry* result = GEOSGeom_createLineString(seq);
-    GEOSGeometry* expected = GEOSGeomFromWKT("LINESTRING (1 2, 4 5, 9 -2)");
+    result_ = GEOSGeom_createLineString(seq);
+    expected_ = fromWKT("LINESTRING (1 2, 4 5, 9 -2)");
 
-    ensure_equals(GEOSEqualsExact(result, expected, 0), 1);
-
-    GEOSGeom_destroy(result);
-    GEOSGeom_destroy(expected);
+    ensure_geometry_equals(result_, expected_, 0);
 }
 
 } // namespace tut
diff --git a/tests/unit/capi/GEOSGeom_extentTest.cpp b/tests/unit/capi/GEOSGeom_extentTest.cpp
index 9b44ce670..bf31bd9c8 100644
--- a/tests/unit/capi/GEOSGeom_extentTest.cpp
+++ b/tests/unit/capi/GEOSGeom_extentTest.cpp
@@ -21,50 +21,43 @@ group test_capigeosgeom_extent_group("capi::GEOSGeom_extent");
 
 template<>
 template<>
-void object::test<1>
-()
+void object::test<1>()
 {
-    GEOSGeometry* g = GEOSGeomFromWKT("LINESTRING (3 8, -12 -4)");
+    geom1_ = fromWKT("LINESTRING (3 8, -12 -4)");
 
     double xmin, ymin, xmax, ymax;
 
-    ensure(GEOSGeom_getXMin(g, &xmin) != 0);
-    ensure(GEOSGeom_getYMin(g, &ymin) != 0);
-    ensure(GEOSGeom_getXMax(g, &xmax) != 0);
-    ensure(GEOSGeom_getYMax(g, &ymax) != 0);
+    ensure(GEOSGeom_getXMin(geom1_, &xmin) != 0);
+    ensure(GEOSGeom_getYMin(geom1_, &ymin) != 0);
+    ensure(GEOSGeom_getXMax(geom1_, &xmax) != 0);
+    ensure(GEOSGeom_getYMax(geom1_, &ymax) != 0);
 
     ensure_equals(xmin, -12);
     ensure_equals(xmax, 3);
     ensure_equals(ymin, -4);
     ensure_equals(ymax, 8);
 
-    ensure(GEOSGeom_getExtent(g, &xmin, &ymin, &xmax, &ymax) != 0);
+    ensure(GEOSGeom_getExtent(geom1_, &xmin, &ymin, &xmax, &ymax) != 0);
 
     ensure_equals(xmin, -12);
     ensure_equals(xmax, 3);
     ensure_equals(ymin, -4);
     ensure_equals(ymax, 8);
-
-    GEOSGeom_destroy(g);
 }
 
 template<>
 template<>
-void object::test<2>
-()
+void object::test<2>()
 {
-    GEOSGeometry* g = GEOSGeomFromWKT("POLYGON EMPTY");
-
     double d;
+    geom1_ = fromWKT("POLYGON EMPTY");
 
-    ensure_equals(GEOSGeom_getXMax(g, &d), 0);
-    ensure_equals(GEOSGeom_getYMax(g, &d), 0);
-    ensure_equals(GEOSGeom_getXMin(g, &d), 0);
-    ensure_equals(GEOSGeom_getYMin(g, &d), 0);
+    ensure_equals(GEOSGeom_getXMax(geom1_, &d), 0);
+    ensure_equals(GEOSGeom_getYMax(geom1_, &d), 0);
+    ensure_equals(GEOSGeom_getXMin(geom1_, &d), 0);
+    ensure_equals(GEOSGeom_getYMin(geom1_, &d), 0);
 
-    ensure_equals(GEOSGeom_getExtent(g, &d, &d, &d, &d), 0);
-
-    GEOSGeom_destroy(g);
+    ensure_equals(GEOSGeom_getExtent(geom1_, &d, &d, &d, &d), 0);
 }
 
 } // namespace tut
diff --git a/tests/unit/capi/GEOSGeom_extractUniquePointsTest.cpp b/tests/unit/capi/GEOSGeom_extractUniquePointsTest.cpp
index afd99076e..b2b531b36 100644
--- a/tests/unit/capi/GEOSGeom_extractUniquePointsTest.cpp
+++ b/tests/unit/capi/GEOSGeom_extractUniquePointsTest.cpp
@@ -9,52 +9,15 @@
 #include <cstdio>
 #include <cstdlib>
 
+#include "capi_test_utils.h"
+
 namespace tut {
 //
 // Test Group
 //
 
 // Common data used in test cases.
-struct test_capigeosextractuniquepoints_data {
-    GEOSGeometry* geom1_;
-    GEOSGeometry* geom2_;
-    GEOSGeometry* geom3_;
-    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_capigeosextractuniquepoints_data()
-        : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr)
-    {
-        handle_ = initGEOS_r(notice, notice);
-    }
-
-    ~test_capigeosextractuniquepoints_data()
-    {
-        GEOSGeom_destroy_r(handle_, geom1_);
-        GEOSGeom_destroy_r(handle_, geom2_);
-        if(geom3_) {
-            GEOSGeom_destroy_r(handle_, geom3_);
-        }
-
-        geom1_ = nullptr;
-        geom2_ = nullptr;
-        geom3_ = nullptr;
-        finishGEOS_r(handle_);
-    }
-
-};
+struct test_capigeosextractuniquepoints_data : public capitest::utility {};
 
 typedef test_group<test_capigeosextractuniquepoints_data> group;
 typedef group::object object;
@@ -70,10 +33,11 @@ template<>
 void object::test<1>
 ()
 {
-    geom1_ = GEOSGeomFromWKT_r(handle_, "POLYGON EMPTY");
-    /* ensure_equals(GEOSGetNumGeometries_r(handle_, geom2_), 0); */
-    geom3_ = GEOSGeom_extractUniquePoints_r(handle_, geom1_);
-    ensure(0 != GEOSisEmpty_r(handle_, geom3_));
+    geom1_ = fromWKT("POLYGON EMPTY");
+    // ensure_equals(GEOSGetNumGeometries(geom2_), 0);
+    geom3_ = GEOSGeom_extractUniquePoints(geom1_);
+    ensure(geom3_ != nullptr);
+    ensure(0 != GEOSisEmpty(geom3_));
 }
 
 template<>
@@ -81,11 +45,12 @@ template<>
 void object::test<2>
 ()
 {
-    geom1_ = GEOSGeomFromWKT_r(handle_, "MULTIPOINT((0 0), (0 0), (1 1))");
-    geom2_ = GEOSGeomFromWKT_r(handle_, "MULTIPOINT((0 0), (1 1))");
-    /* ensure_equals(GEOSGetNumGeometries_r(handle_, geom2_), 0); */
-    geom3_ = GEOSGeom_extractUniquePoints_r(handle_, geom1_);
-    ensure(0 != GEOSEquals_r(handle_, geom3_, geom2_));
+    geom1_ = fromWKT("MULTIPOINT((0 0), (0 0), (1 1))");
+    geom2_ = fromWKT("MULTIPOINT((0 0), (1 1))");
+    /* ensure_equals(GEOSGetNumGeometries(geom2_), 0); */
+    geom3_ = GEOSGeom_extractUniquePoints(geom1_);
+    ensure(geom3_);
+    ensure_geometry_equals(geom3_, geom2_);
 }
 
 template<>
@@ -93,12 +58,11 @@ template<>
 void object::test<3>
 ()
 {
-    geom1_ = GEOSGeomFromWKT_r(handle_,
-                               "GEOMETRYCOLLECTION(MULTIPOINT((0 0), (0 0), (1 1)),LINESTRING(1 1, 2 2, 2 2, 0 0),POLYGON((5 5, 0 0, 0 2, 2 2, 5 5)))");
-    geom2_ = GEOSGeomFromWKT_r(handle_, "MULTIPOINT((0 0), (1 1), (2 2), (5 5), (0 2))");
-    geom3_ = GEOSGeom_extractUniquePoints_r(handle_, geom1_);
-    /* ensure_equals(GEOSGetNumGeometries_r(handle_, geom2_), 0); */
-    ensure(0 != GEOSEquals_r(handle_, geom3_, geom2_));
+    geom1_ = fromWKT("GEOMETRYCOLLECTION(MULTIPOINT((0 0), (0 0), (1 1)),LINESTRING(1 1, 2 2, 2 2, 0 0),POLYGON((5 5, 0 0, 0 2, 2 2, 5 5)))");
+    geom2_ = fromWKT("MULTIPOINT((0 0), (1 1), (2 2), (5 5), (0 2))");
+    geom3_ = GEOSGeom_extractUniquePoints(geom1_);
+    /* ensure_equals(GEOSGetNumGeometries(geom2_), 0); */
+    ensure_geometry_equals(geom3_, geom2_);
 }
 
 
diff --git a/tests/unit/capi/GEOSGeom_getCoordSeqTest.cpp b/tests/unit/capi/GEOSGeom_getCoordSeqTest.cpp
index cbb134df9..bd8459788 100644
--- a/tests/unit/capi/GEOSGeom_getCoordSeqTest.cpp
+++ b/tests/unit/capi/GEOSGeom_getCoordSeqTest.cpp
@@ -21,7 +21,7 @@ template<>
 void object::test<1>
 ()
 {
-    input_ = GEOSGeomFromWKT("LINESTRING (1 2, 4 5, 9 -2)");
+    input_ = fromWKT("LINESTRING (1 2, 4 5, 9 -2)");
     const GEOSCoordSequence* seq = GEOSGeom_getCoordSeq(input_);
 
     double x = -1;
@@ -36,7 +36,7 @@ template<>
 template<>
 void object::test<2>()
 {
-    input_ = GEOSGeomFromWKT("POLYGON ((1 1, 2 1, 2 2, 1 1))");
+    input_ = fromWKT("POLYGON ((1 1, 2 1, 2 2, 1 1))");
     const GEOSCoordSequence* seq = GEOSGeom_getCoordSeq(input_);
 
     ensure(seq == nullptr); // can't get seq from Polygon
@@ -46,7 +46,7 @@ template<>
 template<>
 void object::test<3>()
 {
-    input_ = GEOSGeomFromWKT("POINT (3 8)");
+    input_ = fromWKT("POINT (3 8)");
     const GEOSCoordSequence* seq = GEOSGeom_getCoordSeq(input_);
 
     double x = -1;
diff --git a/tests/unit/capi/GEOSGeom_getCoordinateDimensionTest.cpp b/tests/unit/capi/GEOSGeom_getCoordinateDimensionTest.cpp
index 9f3eda5a1..8d0b0ce6f 100644
--- a/tests/unit/capi/GEOSGeom_getCoordinateDimensionTest.cpp
+++ b/tests/unit/capi/GEOSGeom_getCoordinateDimensionTest.cpp
@@ -21,17 +21,14 @@ template<>
 void object::test<1>
 ()
 {
-    GEOSGeometry* point = GEOSGeomFromWKT("POINT (4 2 7)");
-    GEOSGeometry* line = GEOSGeomFromWKT("LINESTRING (4 2 7 1, 8 2 9 5)");
-    GEOSGeometry* poly = GEOSGeomFromWKT("POLYGON ((0 0, 1 0, 1 1, 0 0))");
+    geom1_ = fromWKT("POLYGON ((0 0, 1 0, 1 1, 0 0))");
+    ensure_equals(GEOSGeom_getCoordinateDimension(geom1_), 2);
 
-    ensure_equals(GEOSGeom_getCoordinateDimension(point), 3);
-    ensure_equals(GEOSGeom_getCoordinateDimension(line), 4);
-    ensure_equals(GEOSGeom_getCoordinateDimension(poly), 2);
+    geom2_ = fromWKT("POINT (4 2 7)");
+    ensure_equals(GEOSGeom_getCoordinateDimension(geom2_), 3);
 
-    GEOSGeom_destroy(point);
-    GEOSGeom_destroy(line);
-    GEOSGeom_destroy(poly);
+    geom3_ = fromWKT("LINESTRING (4 2 7 1, 8 2 9 5)");
+    ensure_equals(GEOSGeom_getCoordinateDimension(geom3_), 4);
 }
 
 } // namespace tut
diff --git a/tests/unit/capi/GEOSGeom_getDimensionsTest.cpp b/tests/unit/capi/GEOSGeom_getDimensionsTest.cpp
index d81d1d2d4..c90e3e0ae 100644
--- a/tests/unit/capi/GEOSGeom_getDimensionsTest.cpp
+++ b/tests/unit/capi/GEOSGeom_getDimensionsTest.cpp
@@ -21,17 +21,14 @@ template<>
 void object::test<1>
 ()
 {
-    GEOSGeometry* point = GEOSGeomFromWKT("POINT (4 2 7)");
-    GEOSGeometry* line = GEOSGeomFromWKT("LINESTRING (4 2 7 1, 8 2 9 5)");
-    GEOSGeometry* poly = GEOSGeomFromWKT("POLYGON ((0 0, 1 0, 1 1, 0 0))");
+    geom1_ = fromWKT("POLYGON ((0 0, 1 0, 1 1, 0 0))");
+    ensure_equals(GEOSGeom_getDimensions(geom1_), 2);
 
-    ensure_equals(GEOSGeom_getDimensions(point), 0);
-    ensure_equals(GEOSGeom_getDimensions(line), 1);
-    ensure_equals(GEOSGeom_getDimensions(poly), 2);
+    geom3_ = fromWKT("LINESTRING (4 2 7 1, 8 2 9 5)");
+    ensure_equals(GEOSGeom_getDimensions(geom3_), 1);
 
-    GEOSGeom_destroy(point);
-    GEOSGeom_destroy(line);
-    GEOSGeom_destroy(poly);
+    geom2_ = fromWKT("POINT (4 2 7)");
+    ensure_equals(GEOSGeom_getDimensions(geom2_), 0);
 }
 
 } // namespace tut

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

Summary of changes:
 tests/unit/capi/GEOSEqualsTest.cpp                 |  50 ++----
 tests/unit/capi/GEOSFrechetDistanceTest.cpp        |  29 ++--
 tests/unit/capi/GEOSGeom_createCollectionTest.cpp  | 185 +++++++++------------
 tests/unit/capi/GEOSGeom_createLineStringTest.cpp  |  10 +-
 tests/unit/capi/GEOSGeom_extentTest.cpp            |  35 ++--
 .../unit/capi/GEOSGeom_extractUniquePointsTest.cpp |  74 +++------
 tests/unit/capi/GEOSGeom_getCoordSeqTest.cpp       |   6 +-
 .../capi/GEOSGeom_getCoordinateDimensionTest.cpp   |  15 +-
 tests/unit/capi/GEOSGeom_getDimensionsTest.cpp     |  15 +-
 9 files changed, 154 insertions(+), 265 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list