[geos-commits] r4338 - trunk/tests/unit/geom

Mateusz Loskot mateusz at loskot.net
Wed Feb 15 14:31:02 PST 2017


Author: mloskot
Date: 2017-02-15 14:31:02 -0800 (Wed, 15 Feb 2017)
New Revision: 4338

Modified:
   trunk/tests/unit/geom/PolygonTest.cpp
Log:
Add basic test of convex Polygon::buffer(0) result.

Modified: trunk/tests/unit/geom/PolygonTest.cpp
===================================================================
--- trunk/tests/unit/geom/PolygonTest.cpp	2017-02-14 16:38:04 UTC (rev 4337)
+++ trunk/tests/unit/geom/PolygonTest.cpp	2017-02-15 22:31:02 UTC (rev 4338)
@@ -1,4 +1,4 @@
-// 
+//
 // Test Suite for geos::geom::Polygon class.
 
 #include <tut.hpp>
@@ -43,7 +43,7 @@
 		PolygonPtr poly_;
 		const size_t poly_size_;
 
-		test_polygon_data() 
+		test_polygon_data()
 			: pm_(1)
       , factory_(GeometryFactory::create(&pm_, 0))
       , reader_(factory_.get())
@@ -55,7 +55,7 @@
 			poly_ = dynamic_cast<PolygonPtr>(geo);
 		}
 
-        ~test_polygon_data() 
+        ~test_polygon_data()
         {
             // FREE MEMORY
             factory_->destroyGeometry(poly_);
@@ -110,11 +110,11 @@
 			// Exterior (clone is required here because Polygon takes ownership)
 			GeometryPtr geo = ring.clone();
 			LinearRingPtr exterior = dynamic_cast<LinearRingPtr>(geo);
-			
+
 			// Create non-empty Polygon
 			//geos::geom::Polygon poly(exterior, 0, &factory_);
 			PolygonAutoPtr poly(factory_->createPolygon(exterior, 0));
-			
+
 			ensure( !poly->isEmpty() );
 			ensure( poly->isSimple() );
 			ensure( poly->isValid() );
@@ -186,7 +186,7 @@
 	template<>
 	void object::test<7>()
 	{
-		GeometryPtr boundary = empty_poly_->getBoundary();	
+		GeometryPtr boundary = empty_poly_->getBoundary();
 		ensure( boundary != 0 );
 		ensure( boundary->isEmpty() );
 		factory_->destroyGeometry(boundary);
@@ -197,7 +197,7 @@
 	template<>
 	void object::test<8>()
 	{
-		GeometryPtr hull = empty_poly_->convexHull();	
+		GeometryPtr hull = empty_poly_->convexHull();
 		ensure( hull != 0 );
 		ensure( hull->isEmpty() );
 		factory_->destroyGeometry(hull);
@@ -225,7 +225,7 @@
 	void object::test<11>()
 	{
 		ensure_equals( empty_poly_->getBoundaryDimension(), geos::geom::Dimension::L );
-	}	
+	}
 
 	// Test of getNumPoints() for empty Polygon
 	template<>
@@ -250,7 +250,7 @@
 	{
 		ensure_equals( empty_poly_->getArea(), 0.0 );
 	}
-    
+
     // Test of isEmpty() for non-empty Polygon
     template<>
     template<>
@@ -267,7 +267,7 @@
 	{
 		ensure( poly_ != 0 );
 
-		GeometryPtr envelope = poly_->getEnvelope();	
+		GeometryPtr envelope = poly_->getEnvelope();
 		ensure( envelope != 0 );
 		ensure( !envelope->isEmpty() );
 		ensure_equals( envelope->getDimension(), geos::geom::Dimension::A );
@@ -283,7 +283,7 @@
 	{
 		ensure( poly_ != 0 );
 
-		GeometryPtr boundary = poly_->getBoundary();	
+		GeometryPtr boundary = poly_->getBoundary();
 		ensure( boundary != 0 );
 
 		// OGC 05-126, Version: 1.1.0, Chapter 6.1.10 Surface
@@ -300,7 +300,7 @@
 	{
 		ensure( poly_ != 0 );
 
-		GeometryPtr hull = poly_->convexHull();	
+		GeometryPtr hull = poly_->convexHull();
 		ensure( hull != 0 );
 		ensure( !hull->isEmpty() );
 		ensure_equals( hull->getGeometryTypeId(), geos::geom::GEOS_POLYGON );
@@ -368,7 +368,7 @@
 		ensure( poly_ != 0 );
 		ensure( poly_->getArea() != 0.0 );
 	}
-	
+
 	// Test of getCoordinates() for non-empty Polygon
     template<>
     template<>
@@ -433,7 +433,7 @@
 		geo = reader_.read("POLYGON ((0 0, 100 0, 100 100, 0 100, 0 0), (1 1, 1 10, 10 10, 10 1, 1 1) )");
 		ensure( geo != 0 );
 		ensure_equals( geo->getGeometryTypeId(), geos::geom::GEOS_POLYGON );
-		
+
 		PolygonPtr poly = dynamic_cast<PolygonPtr>(geo);
 		ensure( poly != 0 );
 		ensure_equals( poly->getNumInteriorRing(), holesNum );
@@ -501,7 +501,7 @@
     template<>
     template<>
     void object::test<34>()
-	{		
+	{
 		PointPtr point = empty_poly_->getCentroid();
 		ensure( point == 0 );
 	}
@@ -510,7 +510,7 @@
     template<>
     template<>
     void object::test<35>()
-	{	
+	{
 		geos::geom::Coordinate centroid;
 		bool isCentroid = empty_poly_->getCentroid(centroid);
 		ensure( !isCentroid );
@@ -534,7 +534,7 @@
     template<>
     template<>
     void object::test<37>()
-	{	
+	{
 		geos::geom::Coordinate centroid;
 		bool isCentroid = poly_->getCentroid(centroid);
 		ensure( isCentroid );
@@ -566,5 +566,16 @@
 		ensure_equals( "Check Polygon::getCentroid() functions.", coordCentr, pointCentr );
 	}
 
+	// Test of Geometry::buffer(0) with convex polygon
+    template<>
+    template<>
+    void object::test<39>()
+	{
+		GeometryPtr gBuffer(poly_->buffer(0));
+        ensure_not(gBuffer->isEmpty());
+        ensure(gBuffer->isValid());
+        ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+        ensure(gBuffer->getNumPoints() == poly_->getNumPoints());
+	}
 
 } // namespace tut



More information about the geos-commits mailing list