From 5ab4c003690424a390c04e44b7801c83504a2708 Mon Sep 17 00:00:00 2001 From: Martin Davis Date: Tue, 21 Jan 2025 22:32:54 -0800 Subject: [PATCH] More code simplification --- tests/xmltester/XMLTester.cpp | 48 +++++++---------------------------- tests/xmltester/XMLTester.h | 8 +++--- 2 files changed, 13 insertions(+), 43 deletions(-) diff --git a/tests/xmltester/XMLTester.cpp b/tests/xmltester/XMLTester.cpp index 09c025d37..ef260fb13 100644 --- a/tests/xmltester/XMLTester.cpp +++ b/tests/xmltester/XMLTester.cpp @@ -619,9 +619,6 @@ XMLTester::parseCase(const tinyxml2::XMLNode* node) gA = nullptr; gB = nullptr; - - //dump_to_stdout(node); - curr_case_desc.clear(); const tinyxml2::XMLNode* txt = node->FirstChildElement("desc"); if(txt) { @@ -630,10 +627,6 @@ XMLTester::parseCase(const tinyxml2::XMLNode* node) curr_case_desc = trimBlanks(txt->Value()); } } - - //std::cerr << "Desc: " << curr_case_desc << std::endl; - - try { const tinyxml2::XMLNode* el = node->FirstChildElement("a"); geomAin = el->FirstChild()->Value(); @@ -1125,7 +1118,7 @@ void Test::executeOp(Geometry* gA, Geometry* gB) checkResult( den.getResultGeometry().get() ); } else if(opName == "intersects") { - if (tester.isUsePrepared()) { + if (tester.isPrepared()) { checkResult( prepare(gA)->intersects(gB)); } else { @@ -1133,7 +1126,7 @@ void Test::executeOp(Geometry* gA, Geometry* gB) } } else if(opName == "contains") { - if (tester.isUsePrepared()) { + if (tester.isPrepared()) { checkResult( prepare(gA)->contains(gB)); } else { @@ -1141,7 +1134,7 @@ void Test::executeOp(Geometry* gA, Geometry* gB) } } else if(opName == "overlaps") { - if (tester.isUsePrepared()) { + if (tester.isPrepared()) { checkResult( prepare(gA)->overlaps(gB)); } else { @@ -1149,7 +1142,7 @@ void Test::executeOp(Geometry* gA, Geometry* gB) } } else if(opName == "within") { - if (tester.isUsePrepared()) { + if (tester.isPrepared()) { checkResult( prepare(gA)->within(gB)); } else { @@ -1157,7 +1150,7 @@ void Test::executeOp(Geometry* gA, Geometry* gB) } } else if(opName == "touches") { - if (tester.isUsePrepared()) { + if (tester.isPrepared()) { checkResult( prepare(gA)->touches(gB)); } else { @@ -1165,7 +1158,7 @@ void Test::executeOp(Geometry* gA, Geometry* gB) } } else if(opName == "crosses") { - if (tester.isUsePrepared()) { + if (tester.isPrepared()) { checkResult( prepare(gA)->crosses(gB)); } else { @@ -1173,7 +1166,7 @@ void Test::executeOp(Geometry* gA, Geometry* gB) } } else if(opName == "disjoint") { - if (tester.isUsePrepared()) { + if (tester.isPrepared()) { checkResult( prepare(gA)->disjoint(gB)); } else { @@ -1181,7 +1174,7 @@ void Test::executeOp(Geometry* gA, Geometry* gB) } } else if(opName == "covers") { - if (tester.isUsePrepared()) { + if (tester.isPrepared()) { checkResult( prepare(gA)->covers(gB)); } else { @@ -1204,7 +1197,7 @@ void Test::executeOp(Geometry* gA, Geometry* gB) checkResult( gA->equalsExact(gB)); } else if(opName == "coveredby") { - if (tester.isUsePrepared()) { + if (tester.isPrepared()) { checkResult( prepare(gA)->coveredBy(gB)); } else { @@ -1367,49 +1360,26 @@ void Test::executeOp(Geometry* gA, Geometry* gB) throw std::runtime_error("malformed testcase: missing tolerated area difference in 'areatest' op"); } - if(verbose > 1) { - std::cerr << "Running intersection for areatest" << std::endl; - } std::unique_ptr gI(gA->intersection(gB)); - if(testValidOutput) { validOut &= tester.testValid(gI.get(), "areatest intersection"); } - if(verbose > 1) { - std::cerr << "Running difference(A,B) for areatest" << std::endl; - } - std::unique_ptr gDab(gA->difference(gB)); - if(testValidOutput) { validOut &= tester.testValid(gI.get(), "areatest difference(a,b)"); } - if(verbose > 1) { - std::cerr << "Running difference(B,A) for areatest" << std::endl; - } - std::unique_ptr gDba(gB->difference(gA)); - if(testValidOutput) { validOut &= tester.testValid(gI.get(), "areatest difference(b,a)"); } - if(verbose > 1) { - std::cerr << "Running symdifference for areatest" << std::endl; - } - std::unique_ptr gSD(gA->symDifference(gB)); - if(testValidOutput) { validOut &= tester.testValid(gI.get(), "areatest symdifference"); } - if(verbose > 1) { - std::cerr << "Running union for areatest" << std::endl; - } - std::unique_ptr gU(gA->Union(gB)); double areaA = gA->getArea(); diff --git a/tests/xmltester/XMLTester.h b/tests/xmltester/XMLTester.h index 4b54d2933..002f4f632 100644 --- a/tests/xmltester/XMLTester.h +++ b/tests/xmltester/XMLTester.h @@ -102,7 +102,7 @@ class XMLTester { bool isTestValidOutput() { return testValidOutput; } - bool isUsePrepared() { return usePrepared; } + bool isPrepared() { return usePrepared; } geom::GeometryFactory* getFactory() { return factory.get(); } @@ -135,6 +135,9 @@ class XMLTester { }; +/* + Executes a single test in a XML test file. +*/ class Test { private: XMLTester& tester; @@ -148,7 +151,6 @@ class Test { std::string opSignature; //TODO: make these functions on XMLTester? - int verbose; bool testValidOutput; bool isSuccess; @@ -174,9 +176,7 @@ class Test { isSuccess(false), actual_result("NONE") { - verbose = tester.isVerbose(); testValidOutput = tester.isTestValidOutput(); - //usePrepared = tester.isUsePrepared(); } bool run(const tinyxml2::XMLNode* node, Geometry* geomA, Geometry* geomB);