[geos-commits] r3899 - in trunk: include/geos/triangulate/quadedge src/triangulate/quadedge tests/unit tests/unit/triangulate/quadedge

svn_geos at osgeo.org svn_geos at osgeo.org
Tue Aug 20 05:15:05 PDT 2013


Author: strk
Date: 2013-08-20 05:15:03 -0700 (Tue, 20 Aug 2013)
New Revision: 3899

Added:
   trunk/tests/unit/triangulate/quadedge/VertexTest.cpp
Modified:
   trunk/include/geos/triangulate/quadedge/Vertex.h
   trunk/src/triangulate/quadedge/Vertex.cpp
   trunk/tests/unit/Makefile.am
Log:
operator< for Vertex added

Includes test

Path by Vishal Tiwari

Modified: trunk/include/geos/triangulate/quadedge/Vertex.h
===================================================================
--- trunk/include/geos/triangulate/quadedge/Vertex.h	2013-08-19 15:45:47 UTC (rev 3898)
+++ trunk/include/geos/triangulate/quadedge/Vertex.h	2013-08-20 12:15:03 UTC (rev 3899)
@@ -265,6 +265,8 @@
 			const geom::Coordinate &p1);
 };
 
+GEOS_DLL bool operator<(const Vertex& v1 ,const Vertex& v2);
+
 } //namespace geos.triangulate.quadedge
 } //namespace geos.triangulate
 } //namespace geos

Modified: trunk/src/triangulate/quadedge/Vertex.cpp
===================================================================
--- trunk/src/triangulate/quadedge/Vertex.cpp	2013-08-19 15:45:47 UTC (rev 3898)
+++ trunk/src/triangulate/quadedge/Vertex.cpp	2013-08-20 12:15:03 UTC (rev 3899)
@@ -190,6 +190,16 @@
 	return pz;
 }
 
+bool operator<(const Vertex& v1 ,const Vertex& v2) 
+{
+	if(v1.getCoordinate().x < v2.getCoordinate().x)
+		return 1;
+	else if(v1.getCoordinate().x == v2.getCoordinate().x && v1.getCoordinate().y < v2.getCoordinate().y)
+		return 1;
+	return 0;
+}
+
+
 } //namespace geos.triangulate.quadedge
 } //namespace geos.triangulate
 } //namespace geos

Modified: trunk/tests/unit/Makefile.am
===================================================================
--- trunk/tests/unit/Makefile.am	2013-08-19 15:45:47 UTC (rev 3898)
+++ trunk/tests/unit/Makefile.am	2013-08-20 12:15:03 UTC (rev 3899)
@@ -105,6 +105,7 @@
 	simplify/TopologyPreservingSimplifierTest.cpp \
 	triangulate/quadedge/QuadEdgeTest.cpp \
 	triangulate/quadedge/QuadEdgeSubdivisionTest.cpp \
+	triangulate/quadedge/VertexTest.cpp \
 	triangulate/DelaunayTest.cpp \
 	util/UniqueCoordinateArrayFilterTest.cpp \
 	capi/GEOSCoordSeqTest.cpp \

Added: trunk/tests/unit/triangulate/quadedge/VertexTest.cpp
===================================================================
--- trunk/tests/unit/triangulate/quadedge/VertexTest.cpp	                        (rev 0)
+++ trunk/tests/unit/triangulate/quadedge/VertexTest.cpp	2013-08-20 12:15:03 UTC (rev 3899)
@@ -0,0 +1,60 @@
+
+// 
+// Test Suite for geos::triangulate::quadedge::Vertex
+//
+// tut
+#include <tut.hpp>
+// geos
+#include <geos/triangulate/quadedge/Vertex.h>
+//#include <geos/io/WKTWriter.h>
+#include <geos/geom/Envelope.h>
+// std
+#include <stdio.h>
+
+using namespace geos::triangulate::quadedge;
+
+namespace tut
+{
+	//
+	// Test Group
+	//
+
+	// dummy data, not used
+	struct test_vertex_data
+	{
+		test_vertex_data()
+		{
+		}
+	};
+
+	typedef test_group<test_vertex_data> group;
+	typedef group::object object;
+
+	group test_vertex_group("geos::triangulate::quadedge::Vertex");
+
+
+	//
+	// Test Cases
+	//
+
+	// 1 - Test for operator< 
+	template<>
+	template<>
+	void object::test<1>()
+	{
+		Vertex v1(10,20);
+		Vertex v2(20,30);
+		Vertex v3(0,100);
+		Vertex v4(10,30);
+		Vertex v5(10,10);
+
+		ensure_equals(v1<v2,1);
+		ensure_equals(v1<v3,0u);
+		ensure_equals(v1<v4,1u);
+		ensure_equals(v1<v5,0u);
+		ensure_equals(v4<v5,0u);
+	}
+
+} // namespace tut
+
+



More information about the geos-commits mailing list