diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-04-27 02:59:16 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-04-27 03:15:32 +0200 |
commit | 811899e4a28f8b37c23c07fc524dbf1f3c1b6fb5 (patch) | |
tree | 029b18bb75ee4694f01e5d879192ed1fb09234dd /test | |
parent | e776953fc360ba161e5ac398bcb707962fb741fe (diff) |
improve assert messages
Diffstat (limited to 'test')
-rw-r--r-- | test/source/diff/diff.cxx | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/test/source/diff/diff.cxx b/test/source/diff/diff.cxx index 6b97f298b3b1..4d130232b881 100644 --- a/test/source/diff/diff.cxx +++ b/test/source/diff/diff.cxx @@ -31,6 +31,7 @@ #include <libxml/xpath.h> #include <rtl/math.hxx> #include <cstring> +#include <sstream> #include <cmath> #include <cassert> @@ -94,7 +95,7 @@ void XMLDiff::loadToleranceFile(xmlDocPtr xmlToleranceFile) { xmlNodePtr root = xmlDocGetRootElement(xmlToleranceFile); #if USE_CPPUNIT - CPPUNIT_ASSERT_MESSAGE("did not find tolerance file", xmlStrEqual( root->name, BAD_CAST("tolerances") )); + CPPUNIT_ASSERT_MESSAGE("did not find correct tolerance file", xmlStrEqual( root->name, BAD_CAST("tolerances") )); #else if(!xmlStrEqual( root->name, BAD_CAST("tolerances") )) { @@ -125,7 +126,9 @@ bool XMLDiff::compare() #if USE_CPPUNIT CPPUNIT_ASSERT(root1); CPPUNIT_ASSERT(root2); - CPPUNIT_ASSERT(xmlStrEqual(root1->name, root2->name)); + std::stringstream stringStream("Expected: "); + stringStream << (char*)root1->name << "\nFound: " << (char*) root2->name; + CPPUNIT_ASSERT(stringStream.str(), xmlStrEqual(root1->name, root2->name)); #else if (!root1 || !root2) return false; @@ -155,7 +158,9 @@ bool checkForEmptyChildren(xmlNodePtr node) bool XMLDiff::compareElements(xmlNode* node1, xmlNode* node2) { #if USE_CPPUNIT - CPPUNIT_ASSERT(xmlStrEqual( node1->name, node2->name )); + std::stringstream stringStream("Expected: "); + stringStream << (xmlChar*) node1->name << "\nFound: " << node2->name; + CPPUNIT_ASSERT_MESSAGE(stringStream.str(), xmlStrEqual( node1->name, node2->name )); #else if (!xmlStrEqual( node1->name, node2->name )) return false; @@ -248,7 +253,10 @@ bool XMLDiff::compareAttributes(xmlNodePtr node1, xmlNodePtr node2) { bool valInTolerance = compareValuesWithTolerance(dVal1, dVal2, itr->value, itr->relative); #if USE_CPPUNIT - CPPUNIT_ASSERT(valInTolerance); + std::stringstream stringStream("Expected Value: "); + stringStream << dVal1 << "; Found Value: " << dVal2 << "; Tolerance: " << itr->value; + stringStream << "; Relative: " << itr->relative; + CPPUNIT_ASSERT_MESSAGE(stringStream.str(), valInTolerance); #else if (!valInTolerance) return false; @@ -268,10 +276,12 @@ bool XMLDiff::compareAttributes(xmlNodePtr node1, xmlNodePtr node2) { #if USE_CPPUNIT - CPPUNIT_ASSERT(xmlStrEqual(val1, val2)); + std::stringstream stringStream("Expected: "); + stringStream << (char*)val1 << "\nFound: " << (char*)val2; + CPPUNIT_ASSERT_MESSAGE(stringStream.str(), xmlStrEqual(val1, val2)); #else - if(!xmlStrEqual( val1, val2 )) - return false; + if(!xmlStrEqual( val1, val2 )) + return false; #endif } |