[geos-commits] r2978 - branches/3.2/tests/unit/capi

svn_geos at osgeo.org svn_geos at osgeo.org
Sun Apr 18 05:34:54 EDT 2010


Author: strk
Date: 2010-04-18 05:34:53 -0400 (Sun, 18 Apr 2010)
New Revision: 2978

Added:
   branches/3.2/tests/unit/capi/GEOSGetCentroidTest.cpp
Log:
Forgot to add this, since I added the Makefile.am line..


Added: branches/3.2/tests/unit/capi/GEOSGetCentroidTest.cpp
===================================================================
--- branches/3.2/tests/unit/capi/GEOSGetCentroidTest.cpp	                        (rev 0)
+++ branches/3.2/tests/unit/capi/GEOSGetCentroidTest.cpp	2010-04-18 09:34:53 UTC (rev 2978)
@@ -0,0 +1,82 @@
+// $Id$
+// 
+// Test Suite for C-API GEOSGetCentroid
+
+#include <tut.hpp>
+// geos
+#include <geos_c.h>
+// std
+#include <cstdarg>
+#include <cstdio>
+#include <cstdlib>
+#include <memory>
+
+namespace tut
+{
+    //
+    // Test Group
+    //
+
+    // Common data used in test cases.
+    struct test_capigeosgetcentroid_data
+    {
+
+        GEOSGeometry* geom1_;
+        GEOSGeometry* geom2_;
+
+        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_capigeosgetcentroid_data() 
+            : geom1_(0), geom2_(0)
+        {
+            initGEOS(notice, notice);
+        }       
+
+        ~test_capigeosgetcentroid_data()
+        {
+            GEOSGeom_destroy(geom1_);
+            GEOSGeom_destroy(geom2_);
+            geom1_ = 0;
+            geom2_ = 0;
+            finishGEOS();
+        }
+
+    };
+
+    typedef test_group<test_capigeosgetcentroid_data> group;
+    typedef group::object object;
+
+    group test_capigeosgetcentroid_group("capi::GEOSGetCentroid");
+
+    //
+    // Test Cases
+    //
+
+    /* More of a leak test */
+    template<>
+    template<>
+    void object::test<1>()
+    {
+        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0)");
+
+        ensure ( ! GEOSisEmpty(geom1_) );
+
+	geom2_ = GEOSGetCentroid(geom1_);
+
+        ensure ( ! GEOSisEmpty(geom2_) );
+
+    }   
+    
+    
+} // namespace tut
+



More information about the geos-commits mailing list