[geos-commits] r3668 - trunk/tests/unit/capi
svn_geos at osgeo.org
svn_geos at osgeo.org
Thu Jun 7 03:23:58 PDT 2012
Author: strk
Date: 2012-06-07 03:23:57 -0700 (Thu, 07 Jun 2012)
New Revision: 3668
Modified:
trunk/tests/unit/capi/GEOSInterruptTest.cpp
Log:
Test that initGEOS clears the interrupt callback
Also explicitly cleanup the callback after each test.
Modified: trunk/tests/unit/capi/GEOSInterruptTest.cpp
===================================================================
--- trunk/tests/unit/capi/GEOSInterruptTest.cpp 2012-06-07 10:23:47 UTC (rev 3667)
+++ trunk/tests/unit/capi/GEOSInterruptTest.cpp 2012-06-07 10:23:57 UTC (rev 3668)
@@ -73,10 +73,11 @@
void object::test<1>()
{
int numcalls = 0;
- GEOS_interruptRegisterCallback(countCalls, &numcalls);
initGEOS(notice, notice);
+ GEOS_interruptRegisterCallback(countCalls, &numcalls);
+
ensure_equals(numcalls, 0);
GEOSGeometry *geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 0)");
@@ -92,26 +93,60 @@
GEOSGeom_destroy(geom1);
GEOSGeom_destroy(geom2);
+ GEOS_interruptRegisterCallback(0, 0); /* unregister */
+
+
finishGEOS();
}
- /// Test interrupting from callback
+ /// Test interrupt callback being reset by initGEOS
template<>
template<>
void object::test<2>()
{
+ int numcalls = 0;
+
+ GEOS_interruptRegisterCallback(countCalls, &numcalls);
+
initGEOS(notice, notice);
- GEOS_interruptRegisterCallback(0, 0); /* unregister */
+ ensure_equals(numcalls, 0);
GEOSGeometry *geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 0)");
ensure("GEOSGeomFromWKT failed", 0 != geom1);
+ GEOSGeometry *geom2 = GEOSBuffer(geom1, 1, 8);
+
+ ensure("GEOSBufferWithStyle failed", 0 != geom2);
+
+ ensure_equals(numcalls, 0);
+
+ GEOSGeom_destroy(geom1);
+ GEOSGeom_destroy(geom2);
+
+ GEOS_interruptRegisterCallback(0, 0); /* unregister (shouldn't be needed) */
+
+
+ finishGEOS();
+ }
+
+ /// Test interrupting from callback
+ template<>
+ template<>
+ void object::test<3>()
+ {
+ initGEOS(notice, notice);
+
+ GEOSGeometry *geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 0)");
+
+ ensure("GEOSGeomFromWKT failed", 0 != geom1);
+
GEOS_interruptRegisterCallback(interruptNow, 0);
bool interrupted = false;
GEOSGeometry *geom2 = GEOSBuffer(geom1, 1, 8);
ensure("GEOSBuffer wasn't interrupted", 0 == geom2);
+ GEOS_interruptRegisterCallback(0, 0); /* unregister */
// TODO: check the actual exception ? (sent to notice() callback)
More information about the geos-commits
mailing list