From 9f69b8ccd9d9bc16b9792ed16bc38fa42a304bee Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Sat, 11 Jun 2022 16:18:43 +0200 Subject: [PATCH] tests: more helpful assertion failures from check_nodes Tests would fail as: Test name: AutomationListPropertyTest::basicTest equality assertion failed - Expected: 4 - Actual : 5 It is slightly more informative when the size assertion is the last check and it fails as: - Expected: state - Actual : time-domain The performance benefits from checking size first is not relevant. --- libs/ardour/test/test_util.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libs/ardour/test/test_util.cc b/libs/ardour/test/test_util.cc index 8b4fba6baf..7c2cfcf020 100644 --- a/libs/ardour/test/test_util.cc +++ b/libs/ardour/test/test_util.cc @@ -49,11 +49,10 @@ check_nodes (XMLNode const * p, XMLNode const * q, list const & ignore_p XMLPropertyList const & pp = p->properties (); XMLPropertyList const & qp = q->properties (); - CPPUNIT_ASSERT_EQUAL (qp.size(), pp.size()); XMLPropertyList::const_iterator i = pp.begin (); XMLPropertyList::const_iterator j = qp.begin (); - while (i != pp.end ()) { + while (i != pp.end () && j != qp.end ()) { CPPUNIT_ASSERT_EQUAL ((*j)->name(), (*i)->name()); if (find (ignore_properties.begin(), ignore_properties.end(), (*i)->name ()) == ignore_properties.end ()) { CPPUNIT_ASSERT_EQUAL_MESSAGE ((*j)->name(), (*i)->value(), (*i)->value()); @@ -62,18 +61,21 @@ check_nodes (XMLNode const * p, XMLNode const * q, list const & ignore_p ++j; } + CPPUNIT_ASSERT_EQUAL (qp.size(), pp.size()); + XMLNodeList const & pc = p->children (); XMLNodeList const & qc = q->children (); - CPPUNIT_ASSERT_EQUAL (qc.size(), pc.size()); XMLNodeList::const_iterator k = pc.begin (); XMLNodeList::const_iterator l = qc.begin (); - while (k != pc.end ()) { + while (k != pc.end () && l != qc.end ()) { check_nodes (*k, *l, ignore_properties); ++k; ++l; } + + CPPUNIT_ASSERT_EQUAL (qc.size(), pc.size()); } void