From f4ac43c549fe98157c80c6c3cd9b65fc42e26d08 Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine@gmail.com" Date: Tue, 27 Mar 2012 05:46:44 +0000 Subject: [PATCH] tests: Added xml_named_node_iterator tests git-svn-id: http://pugixml.googlecode.com/svn/trunk@892 99668b35-9821-0410-8761-19e4c4f06640 --- tests/test_dom_traverse.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/test_dom_traverse.cpp b/tests/test_dom_traverse.cpp index 15d6656..3cbcde4 100644 --- a/tests/test_dom_traverse.cpp +++ b/tests/test_dom_traverse.cpp @@ -829,3 +829,37 @@ TEST_XML(dom_hash_value, "value") xml_attribute attr_copy = attr; CHECK(attr_copy.hash_value() == attr.hash_value()); } + +TEST_XML(dom_node_named_iterator, "") +{ + xml_node node1 = doc.child(STR("node")).child(STR("node1")); + xml_node node2 = doc.child(STR("node")).child(STR("node2")); + xml_node node3 = doc.child(STR("node")).child(STR("node3")); + + CHECK(xml_named_node_iterator(xml_node(), STR("child")) == xml_named_node_iterator()); + + xml_named_node_iterator it1(node1.child(STR("child")), STR("child")); + CHECK(move_iter(it1, 1) == xml_named_node_iterator()); + CHECK(*it1 == node1.child(STR("child"))); + CHECK_STRING(it1->name(), STR("child")); + + xml_named_node_iterator it2(node2.child(STR("child")), STR("child")); + CHECK(move_iter(it2, 1) != xml_named_node_iterator()); + CHECK(move_iter(it2, 2) == xml_named_node_iterator()); + CHECK(*it2 == node2.first_child()); + CHECK(*move_iter(it2, 1) == node2.last_child()); + + xml_named_node_iterator it3(node3.child(STR("child")), STR("child")); + CHECK(it3 == xml_named_node_iterator()); + + xml_named_node_iterator it = xml_named_node_iterator(node1.child(STR("child")), STR("child")); + xml_named_node_iterator itt = it; + + CHECK(itt == it); + + CHECK(itt++ == it); + CHECK(itt == xml_named_node_iterator()); + + CHECK(itt != it); + CHECK(itt == ++it); +}