[geos-commits] r2487 - trunk/tests/xmltester
svn_geos at osgeo.org
svn_geos at osgeo.org
Thu May 7 11:36:30 EDT 2009
Author: strk
Date: 2009-05-07 11:36:30 -0400 (Thu, 07 May 2009)
New Revision: 2487
Modified:
trunk/tests/xmltester/XMLTester.cpp
Log:
remove code duplication on buffer result validation
Modified: trunk/tests/xmltester/XMLTester.cpp
===================================================================
--- trunk/tests/xmltester/XMLTester.cpp 2009-05-07 08:52:44 UTC (rev 2486)
+++ trunk/tests/xmltester/XMLTester.cpp 2009-05-07 15:36:30 UTC (rev 2487)
@@ -101,6 +101,52 @@
return newstring;
}
+/* Could be an XMLTester class private but oh well.. */
+static int
+checkBufferSuccess(geom::Geometry& gRes, geom::Geometry& gRealRes, double dist)
+{
+ int success = 1;
+ do
+ {
+
+ if ( gRes.getGeometryTypeId() != gRealRes.getGeometryTypeId() )
+ {
+ std::cerr << "Expected result is of type "
+ << gRes.getGeometryType()
+ << "; obtained result is of type "
+ << gRealRes.getGeometryType()
+ << std::endl;
+ success=0;
+ break;
+ }
+
+ // Is a buffer always an area ?
+ if ( gRes.getDimension() != 2 )
+ {
+ std::cerr << "Don't know how to validate "
+ << "result of buffer operation "
+ << "when expected result is not an "
+ << "areal type."
+ << std::endl;
+ }
+
+
+ geos::xmltester::BufferResultMatcher matcher;
+ if ( ! matcher.isBufferResultMatch(gRealRes,
+ gRes,
+ dist) )
+ {
+std::cerr << "BufferResultMatcher FAILED" << std::endl;
+ success=0;
+ break;
+ }
+
+ }
+ while (0);
+
+ return success;
+}
+
XMLTester::XMLTester()
:
gA(0),
@@ -789,46 +835,9 @@
profile.stop();
gRealRes->normalize();
- // Assume a success and check for obvious failures
- success=1;
- do
- {
+ // Validate the buffer operation
+ success = checkBufferSuccess(*gRes, *gRealRes, dist);
- if ( gRes->getGeometryTypeId() != gRealRes->getGeometryTypeId() )
- {
- std::cerr << "Expected result is of type "
- << gRes->getGeometryType()
- << "; obtained result is of type "
- << gRealRes->getGeometryType()
- << std::endl;
- success=0;
- break;
- }
-
- // Is a buffer always an area ?
- if ( gRes->getDimension() != 2 )
- {
- std::cerr << "Don't know how to validate "
- << "result of buffer operation "
- << "when expected result is not an "
- << "areal type."
- << std::endl;
- }
-
-
- geos::xmltester::BufferResultMatcher matcher;
- if ( ! matcher.isBufferResultMatch(*gRealRes,
- *gRes,
- dist) )
- {
-std::cerr << "BufferResultMatcher FAILED" << std::endl;
- success=0;
- break;
- }
-
- }
- while (0);
-
if ( testValidOutput ) testValid(gRes.get(), "result");
actual_result=printGeom(gRealRes.get());
@@ -863,52 +872,16 @@
profile.stop();
gRealRes->normalize();
- // Assume a success and check for obvious failures
- success=1;
- do
- {
+ // Validate the buffer operation
+ success = checkBufferSuccess(*gRes, *gRealRes, dist);
- if ( gRes->getGeometryTypeId() != gRealRes->getGeometryTypeId() )
- {
- std::cerr << "Expected result is of type "
- << gRes->getGeometryType()
- << "; obtained result is of type "
- << gRealRes->getGeometryType()
- << std::endl;
- success=0;
- break;
- }
-
- // Is a buffer always an area ?
- if ( gRes->getDimension() != 2 )
- {
- std::cerr << "Don't know how to validate "
- << "result of buffer operation "
- << "when expected result is not an "
- << "areal type."
- << std::endl;
- }
-
-
- geos::xmltester::BufferResultMatcher matcher;
- if ( ! matcher.isBufferResultMatch(*gRealRes,
- *gRes,
- dist) )
- {
-std::cerr << "BufferResultMatcher FAILED" << std::endl;
- success=0;
- break;
- }
-
- }
- while (0);
-
if ( testValidOutput ) testValid(gRes.get(), "result");
actual_result=printGeom(gRealRes.get());
expected_result=printGeom(gRes.get());
}
+
else if (opName=="getinteriorpoint")
{
geom::Geometry *gT=gA;
More information about the geos-commits
mailing list