diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-04-30 15:31:14 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-04-30 15:31:14 +0100 |
| commit | 920bbd068a0868bbec7da57724aaf1c14e8b3795 (patch) | |
| tree | eb564968571deeb1bd15db3186fbc2cfc5363281 /test | |
| parent | 868c9d9585d5dda4005c4615766af6c185b7a169 (diff) | |
Fix check_xml that ignored attributes.
Diffstat (limited to 'test')
| -rw-r--r-- | test/test.cc | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/test/test.cc b/test/test.cc index 67d6f2bd2..2620800bc 100644 --- a/test/test.cc +++ b/test/test.cc @@ -225,15 +225,15 @@ check_xml (xmlpp::Element* ref, xmlpp::Element* test, list<string> ignore) if (find (ignore.begin(), ignore.end(), ref->get_name()) != ignore.end ()) { return; } - + xmlpp::Element::NodeList ref_children = ref->get_children (); xmlpp::Element::NodeList test_children = test->get_children (); BOOST_CHECK_EQUAL (ref_children.size (), test_children.size ()); xmlpp::Element::NodeList::iterator k = ref_children.begin (); xmlpp::Element::NodeList::iterator l = test_children.begin (); - while (k != ref_children.end () && l != test_children.end ()) { - + while (k != ref_children.end ()) { + /* XXX: should be doing xmlpp::EntityReference, xmlpp::XIncludeEnd, xmlpp::XIncludeStart */ xmlpp::Element* ref_el = dynamic_cast<xmlpp::Element*> (*k); @@ -250,20 +250,23 @@ check_xml (xmlpp::Element* ref, xmlpp::Element* test, list<string> ignore) BOOST_CHECK_EQUAL (ref_cn->get_content(), test_cn->get_content ()); } - xmlpp::Attribute* ref_at = dynamic_cast<xmlpp::Attribute*> (*k); - xmlpp::Attribute* test_at = dynamic_cast<xmlpp::Attribute*> (*l); - BOOST_CHECK ((ref_at && test_at) || (!ref_at && !test_at)); - if (ref_at && test_at) { - BOOST_CHECK_EQUAL (ref_at->get_name(), test_at->get_name ()); - BOOST_CHECK_EQUAL (ref_at->get_value(), test_at->get_value ()); - } - ++k; ++l; } - BOOST_CHECK (k == ref_children.end ()); - BOOST_CHECK (l == test_children.end ()); + xmlpp::Element::AttributeList ref_attributes = ref->get_attributes (); + xmlpp::Element::AttributeList test_attributes = test->get_attributes (); + BOOST_CHECK_EQUAL (ref_attributes.size(), test_attributes.size ()); + + xmlpp::Element::AttributeList::const_iterator m = ref_attributes.begin(); + xmlpp::Element::AttributeList::const_iterator n = test_attributes.begin(); + while (m != ref_attributes.end ()) { + BOOST_CHECK_EQUAL ((*m)->get_name(), (*n)->get_name()); + BOOST_CHECK_EQUAL ((*m)->get_value(), (*n)->get_value()); + + ++m; + ++n; + } } void |
