summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-05-03 11:50:11 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-05-03 15:16:47 +0200
commit2341569fb082d914fd70b3b93af6346715efaddd (patch)
tree88fb28f592a9db10aa94bfe4215056d517eae21b /test
parent9342656e2fdff4d00fbe305f498aa0b6375f6c75 (diff)
improve assert message in XMLDiff
Change-Id: I561dca23621075753185d7ea2afc5fd174cd2b3d Reviewed-on: https://gerrit.libreoffice.org/71728 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'test')
-rw-r--r--test/source/diff/diff.cxx38
1 files changed, 25 insertions, 13 deletions
diff --git a/test/source/diff/diff.cxx b/test/source/diff/diff.cxx
index e3f7c115d809..483c3954c01a 100644
--- a/test/source/diff/diff.cxx
+++ b/test/source/diff/diff.cxx
@@ -356,12 +356,29 @@ bool XMLDiff::compareAttributes(xmlNodePtr node1, xmlNodePtr node2)
// unequal number of attributes
#ifdef CPPUNIT_ASSERT
- std::stringstream failStream("Unequal number of attributes ");
-
- bool bAttr1 = attr1;
- if (bAttr1)
+ if (attr1 || attr2)
{
- failStream << "Attr1: ";
+ std::stringstream failStream;
+ failStream << "Unequal number of attributes in ";
+ // print chain from document root
+ std::vector<std::string> parents;
+ auto n = node1;
+ while (n)
+ {
+ if (n->name)
+ parents.push_back(std::string(reinterpret_cast<const char *>(n->name)));
+ n = n->parent;
+ }
+ bool first = true;
+ for (auto it = parents.rbegin(); it != parents.rend(); ++it)
+ {
+ if (!first)
+ failStream << "->";
+ first = false;
+ failStream << *it;
+ }
+ failStream << " Attr1: ";
+ attr1 = node1->properties;
while (attr1 != nullptr)
{
xmlChar* val1 = xmlGetProp(node1, attr1->name);
@@ -369,14 +386,9 @@ bool XMLDiff::compareAttributes(xmlNodePtr node1, xmlNodePtr node2)
xmlFree(val1);
attr1 = attr1->next;
}
- }
- CPPUNIT_ASSERT_MESSAGE(failStream.str(), !bAttr1);
-
- bool bAttr2 = attr2;
- if (bAttr2)
- {
- failStream << "Attr2: ";
+ failStream << " Attr2: ";
+ attr2 = node2->properties;
while (attr2 != nullptr)
{
xmlChar* val2 = xmlGetProp(node2, attr2->name);
@@ -384,8 +396,8 @@ bool XMLDiff::compareAttributes(xmlNodePtr node1, xmlNodePtr node2)
xmlFree(val2);
attr2 = attr2->next;
}
+ CPPUNIT_ASSERT_MESSAGE(failStream.str(), false);
}
- CPPUNIT_ASSERT_MESSAGE(failStream.str(), !bAttr2);
#else
if (attr1 || attr2)
return false;