Skip to content

Commit

Permalink
factor out SQL printing
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Jan 22, 2025
1 parent 1fe12d7 commit 50f0c4d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 34 deletions.
70 changes: 36 additions & 34 deletions tests/xmltester/XMLTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,39 +309,45 @@ XMLTester::testcaseRef()

/*private*/
void
XMLTester::printTest(bool success, const std::string& op, const std::string& expected_result, const std::string& actual_result)
XMLTester::printTestSQL(bool success, const std::string& op, const std::string& expected_result, const std::string& actual_result)
{
if(sqlOutput) {
std::cout << "INSERT INTO \"" << normalize_filename(*curr_file) << "\" VALUES ("
<< caseCount << ", "
<< testCount << ", "
//<< "'" << opSignature << "', "
<< "'" << curr_case_desc << "', ";
std::cout << "INSERT INTO \"" << normalize_filename(*curr_file) << "\" VALUES ("
<< caseCount << ", "
<< testCount << ", "
//<< "'" << opSignature << "', "
<< "'" << curr_case_desc << "', ";

std::string geomOut;
std::string geomOut;

if(gA) {
std::cout << "'" << printGeom(gA) << "', ";
}
else {
std::cout << "NULL, ";
}
if(gB) {
std::cout << "'" << printGeom(gB) << "', ";
}
else {
std::cout << "NULL, ";
}
std::cout << "'" << expected_result << "', "
<< "'" << actual_result << "', ";
if(gA) {
std::cout << "'" << printGeom(gA) << "', ";
}
else {
std::cout << "NULL, ";
}
if(gB) {
std::cout << "'" << printGeom(gB) << "', ";
}
else {
std::cout << "NULL, ";
}
std::cout << "'" << expected_result << "', "
<< "'" << actual_result << "', ";

if(success) {
std::cout << "'t'";
}
else {
std::cout << "'f'";
}
std::cout << ");" << std::endl;
if(success) {
std::cout << "'t'";
}
else {
std::cout << "'f'";
}
std::cout << ");" << std::endl;
}

void
XMLTester::printTest(bool success, const std::string& op, const std::string& expected_result, const std::string& actual_result)
{
if(sqlOutput) {
printTestSQL(success, op, expected_result, actual_result);
return;
}
//-- no output for quiet success
Expand All @@ -352,18 +358,15 @@ XMLTester::printTest(bool success, const std::string& op, const std::string& exp
std::cout << op << " " << (success ? "ok." : "failed.");

// print geometry on failure for -v
// print geometry no matter what for -v -v and above
// print geometry always for -v -v and above
if (verbose > 1 || (verbose == 1 && !success)) {
std::cout << "\tDescription: " << curr_case_desc << std::endl;

if(gA) {
std::cout << "\tGeometry A: " << printGeom(gA) << std::endl;
}

if(gB) {
std::cout << "\tGeometry B: " << printGeom(gB) << std::endl;
}

std::cout << "\tExpected: " << expected_result << std::endl;
std::cout << "\tActual: " << actual_result << std::endl;
}
Expand Down Expand Up @@ -412,7 +415,6 @@ XMLTester::run(const std::string& source)
}

parseRun(node);

}

void
Expand Down
1 change: 1 addition & 0 deletions tests/xmltester/XMLTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class XMLTester {
Geometry* parseGeometry(const std::string& in, const char* label = "parsed");
std::string printGeom(const geom::Geometry* g);
void printTest(bool success, const std::string& op, const std::string& expected_result, const std::string& actual_result);
void printTestSQL(bool success, const std::string& op, const std::string& expected_result, const std::string& actual_result);
bool testValid(const geom::Geometry* g, const std::string& label);
std::string testcaseRef();

Expand Down

0 comments on commit 50f0c4d

Please sign in to comment.