summaryrefslogtreecommitdiff
path: root/tests/test_dom_traverse.cpp
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2009-11-08 13:52:55 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2009-11-08 13:52:55 +0000
commit48bbb9f4dd9e6581e61d4d60e132cdb4415f813e (patch)
tree2cab46e9c96b3209161ce60154a11599e26d582b /tests/test_dom_traverse.cpp
parentc8a8b30bddf0df8f137203b0a1533c46358000be (diff)
tests: Extracted generic tests in a separate header, better filter tests, some API tests added
git-svn-id: http://pugixml.googlecode.com/svn/trunk@221 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test_dom_traverse.cpp')
-rw-r--r--tests/test_dom_traverse.cpp86
1 files changed, 12 insertions, 74 deletions
diff --git a/tests/test_dom_traverse.cpp b/tests/test_dom_traverse.cpp
index 0caef27..513263b 100644
--- a/tests/test_dom_traverse.cpp
+++ b/tests/test_dom_traverse.cpp
@@ -6,6 +6,8 @@
#include <vector>
#include <iterator>
+#include "helpers.hpp"
+
#ifdef _MSC_VER
#pragma warning(disable: 4996)
#endif
@@ -25,80 +27,6 @@ template <typename I> static I move_iter(I base, int n)
}
#endif
-template <typename T> static void generic_bool_ops_test(const T& obj)
-{
- T null;
-
- CHECK(!null);
- CHECK(obj);
- CHECK(!!obj);
-
- bool b1 = null, b2 = obj;
-
- CHECK(!b1);
- CHECK(b2);
-}
-
-template <typename T> static void generic_rel_ops_test(T obj1, T obj2)
-{
- T null = T();
-
- // obj1 < obj2 (we use operator<, but there is no other choice
- if (obj1 > obj2) std::swap(obj1, obj2);
-
- // operator==
- CHECK(null == null);
- CHECK(obj1 == obj1);
- CHECK(!(null == obj1));
- CHECK(!(null == obj2));
- CHECK(T(null) == null);
- CHECK(T(obj1) == obj1);
-
- // operator!=
- CHECK(!(null != null));
- CHECK(!(obj1 != obj1));
- CHECK(null != obj1);
- CHECK(null != obj2);
- CHECK(!(T(null) != null));
- CHECK(!(T(obj1) != obj1));
-
- // operator<
- CHECK(null < obj1);
- CHECK(null < obj2);
- CHECK(obj1 < obj2);
- CHECK(!(null < null));
- CHECK(!(obj1 < obj1));
- CHECK(!(obj1 < null));
- CHECK(!(obj2 < obj1));
-
- // operator<=
- CHECK(null <= obj1);
- CHECK(null <= obj2);
- CHECK(obj1 <= obj2);
- CHECK(null <= null);
- CHECK(obj1 <= obj1);
- CHECK(!(obj1 <= null));
- CHECK(!(obj2 <= obj1));
-
- // operator>
- CHECK(obj1 > null);
- CHECK(obj2 > null);
- CHECK(obj2 > obj1);
- CHECK(!(null > null));
- CHECK(!(obj1 > obj1));
- CHECK(!(null > obj1));
- CHECK(!(obj1 > obj2));
-
- // operator>=
- CHECK(obj1 >= null);
- CHECK(obj2 >= null);
- CHECK(obj2 >= obj1);
- CHECK(null >= null);
- CHECK(obj1 >= obj1);
- CHECK(!(null >= obj1));
- CHECK(!(obj1 >= obj2));
-}
-
template <typename T> static void generic_empty_test(const T& obj)
{
T null;
@@ -112,6 +40,11 @@ TEST_XML(dom_attr_bool_ops, "<node attr='1'/>")
generic_bool_ops_test(doc.child("node").attribute("attr"));
}
+TEST_XML(dom_attr_eq_ops, "<node attr1='1' attr2='2'/>")
+{
+ generic_eq_ops_test(doc.child("node").attribute("attr1"), doc.child("node").attribute("attr2"));
+}
+
TEST_XML(dom_attr_rel_ops, "<node attr1='1' attr2='2'/>")
{
generic_rel_ops_test(doc.child("node").attribute("attr1"), doc.child("node").attribute("attr2"));
@@ -250,6 +183,11 @@ TEST_XML(dom_node_bool_ops, "<node/>")
generic_bool_ops_test(doc.child("node"));
}
+TEST_XML(dom_node_eq_ops, "<node><node1/><node2/></node>")
+{
+ generic_eq_ops_test(doc.child("node").child("node1"), doc.child("node").child("node2"));
+}
+
TEST_XML(dom_node_rel_ops, "<node><node1/><node2/></node>")
{
generic_rel_ops_test(doc.child("node").child("node1"), doc.child("node").child("node2"));