summaryrefslogtreecommitdiff
path: root/tests/test_dom_traverse.cpp
diff options
context:
space:
mode:
authorarseny.kapoulkine@gmail.com <arseny.kapoulkine@gmail.com@99668b35-9821-0410-8761-19e4c4f06640>2012-03-27 05:46:44 +0000
committerarseny.kapoulkine@gmail.com <arseny.kapoulkine@gmail.com@99668b35-9821-0410-8761-19e4c4f06640>2012-03-27 05:46:44 +0000
commitf4ac43c549fe98157c80c6c3cd9b65fc42e26d08 (patch)
tree5ae1c6beecae1a5595dd812d74f9a81855579609 /tests/test_dom_traverse.cpp
parenteefd32c2e797fb5fae8185e5c4f707c5a031354a (diff)
tests: Added xml_named_node_iterator tests
git-svn-id: http://pugixml.googlecode.com/svn/trunk@892 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test_dom_traverse.cpp')
-rw-r--r--tests/test_dom_traverse.cpp34
1 files changed, 34 insertions, 0 deletions
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, "<node attr='value'>value</node>")
xml_attribute attr_copy = attr;
CHECK(attr_copy.hash_value() == attr.hash_value());
}
+
+TEST_XML(dom_node_named_iterator, "<node><node1><child/></node1><node2><child/><child/></node2><node3/></node>")
+{
+ 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);
+}