[geos-commits] r2703 - in trunk: . build/msvc90/geos_unit tests/unit tests/unit/operation tests/unit/operation/buffer

svn_geos at osgeo.org svn_geos at osgeo.org
Thu Oct 29 08:33:15 EDT 2009


Author: mloskot
Date: 2009-10-29 08:33:13 -0400 (Thu, 29 Oct 2009)
New Revision: 2703

Added:
   trunk/tests/unit/operation/buffer/
   trunk/tests/unit/operation/buffer/BufferOpTest.cpp
Modified:
   trunk/ChangeLog
   trunk/build/msvc90/geos_unit/geos_unit.vcproj
   trunk/tests/unit/Makefile.am
Log:
* tests/unit/operation/buffer: added unit test case for BufferOp,
* tests/unit/Makefile.am: added new test case source to Makefile,
* build/msvc90/geos_unit/geos_unit.vcproj: updated Visual C++ project.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-10-28 12:09:06 UTC (rev 2702)
+++ trunk/ChangeLog	2009-10-29 12:33:13 UTC (rev 2703)
@@ -1,3 +1,9 @@
+2009-10-29 12:30  Mateusz Loskot <mateusz at loskot.net>
+
+	* [r2703] tests/unit/operation/buffer: added unit test case for BufferOp,
+	  tests/unit/Makefile.am: added new test case source to Makefile,
+	  build/msvc90/geos_unit/geos_unit.vcproj: updated Visual C++ project.
+
 2009-10-28 12:10  Mateusz Loskot <mateusz at loskot.net>
 
 	* [r2702] tests/xmltester/XMLTester.cpp: declare checkBufferSuccess function

Modified: trunk/build/msvc90/geos_unit/geos_unit.vcproj
===================================================================
--- trunk/build/msvc90/geos_unit/geos_unit.vcproj	2009-10-28 12:09:06 UTC (rev 2702)
+++ trunk/build/msvc90/geos_unit/geos_unit.vcproj	2009-10-29 12:33:13 UTC (rev 2703)
@@ -487,6 +487,14 @@
 					>
 				</File>
 			</Filter>
+			<Filter
+				Name="buffer"
+				>
+				<File
+					RelativePath="..\..\..\tests\unit\operation\buffer\BufferOpTest.cpp"
+					>
+				</File>
+			</Filter>
 		</Filter>
 		<Filter
 			Name="precision"
@@ -601,6 +609,10 @@
 			>
 		</File>
 		<File
+			RelativePath="..\..\..\tests\unit\Makefile.am"
+			>
+		</File>
+		<File
 			RelativePath=".\Makefile.am"
 			>
 		</File>

Modified: trunk/tests/unit/Makefile.am
===================================================================
--- trunk/tests/unit/Makefile.am	2009-10-28 12:09:06 UTC (rev 2702)
+++ trunk/tests/unit/Makefile.am	2009-10-29 12:33:13 UTC (rev 2703)
@@ -67,6 +67,7 @@
 	noding/NodedSegmentStringTest.cpp \
 	noding/SegmentNodeTest.cpp \
 	noding/SegmentPointComparatorTest.cpp \
+	operation/buffer/BufferOpTest.cpp \
 	operation/distance/DistanceOpTest.cpp \
 	operation/IsSimpleOpTest.cpp \
 	operation/overlay/validate/FuzzyPointLocatorTest.cpp \

Added: trunk/tests/unit/operation/buffer/BufferOpTest.cpp
===================================================================
--- trunk/tests/unit/operation/buffer/BufferOpTest.cpp	                        (rev 0)
+++ trunk/tests/unit/operation/buffer/BufferOpTest.cpp	2009-10-29 12:33:13 UTC (rev 2703)
@@ -0,0 +1,88 @@
+// $Id$
+// 
+// Test Suite for geos::operation::buffer::BufferOp class.
+
+// tut
+#include <tut.hpp>
+// geos
+#include <geos/operation/buffer/BufferOp.h>
+#include <geos/platform.h>
+#include <geos/geom/Coordinate.h>
+#include <geos/geom/GeometryFactory.h>
+#include <geos/geom/Geometry.h>
+#include <geos/algorithm/PointLocator.h>
+#include <geos/io/WKTReader.h>
+#include <geos/geom/CoordinateSequence.h>
+// std
+#include <memory>
+#include <string>
+#include <vector>
+
+namespace tut
+{
+    //
+    // Test Group
+    //
+
+    // Common data used by tests
+    struct test_bufferop_data
+    {
+        geos::geom::GeometryFactory gf;
+        geos::io::WKTReader wktreader;
+
+        typedef geos::geom::Geometry::AutoPtr GeomPtr;
+        typedef std::auto_ptr<geos::geom::CoordinateSequence> CSPtr;
+
+        test_bufferop_data()
+            : gf(), wktreader(&gf)
+        {}
+    };
+
+    typedef test_group<test_bufferop_data> group;
+    typedef group::object object;
+
+    group test_bufferop_group("geos::operation::buffer::BufferOp");
+
+    //
+    // Test Cases
+    //
+    template<>
+    template<>
+    void object::test<1>()
+    {
+        using geos::operation::buffer::BufferOp;
+        using geos::operation::buffer::BufferParameters;
+
+        std::string wkt0("POINT(0 0)");
+        GeomPtr g0(wktreader.read(wkt0));
+
+        double const distance = 0.0;
+        BufferOp op(g0.get());
+        GeomPtr gBuffer(op.getResultGeometry(distance));
+
+        ensure(gBuffer->isEmpty());
+        ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+        ensure_equals(gBuffer->getNumPoints(), 0);
+    }
+
+    template<>
+    template<>
+    void object::test<2>()
+    {
+        using geos::operation::buffer::BufferOp;
+        using geos::operation::buffer::BufferParameters;
+
+        std::string wkt0("POINT(0 0)");
+        GeomPtr g0(wktreader.read(wkt0));
+
+        // Buffer point with default buffering parameters
+        double const distance = 1.0;
+        BufferOp op(g0.get());
+        GeomPtr gBuffer(op.getResultGeometry(distance));
+
+        ensure_not(gBuffer->isEmpty());
+        ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+        ensure_equals(gBuffer->getNumPoints(), 33);
+    }
+
+} // namespace tut



More information about the geos-commits mailing list