diff options
author | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-10-11 10:24:12 +0000 |
---|---|---|
committer | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-10-11 10:24:12 +0000 |
commit | b6433db22642307330311c42fffb6950287415df (patch) | |
tree | 7df49366af3ae966fa23a42d650ca97a9bfb2efe /tests/test.hpp | |
parent | 473ab359347d6cf4ea5f963bdd04c5ad83cf384f (diff) |
tests: Initial tree modification tests
git-svn-id: http://pugixml.googlecode.com/svn/trunk@148 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test.hpp')
-rw-r--r-- | tests/test.hpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test.hpp b/tests/test.hpp index fa4ef1d..10e32c7 100644 --- a/tests/test.hpp +++ b/tests/test.hpp @@ -3,6 +3,9 @@ #include <string.h>
#include <math.h>
+#include <sstream>
+
+#include "../src/pugixml.hpp"
inline bool test_string_equal(const char* lhs, const char* rhs)
{
@@ -14,6 +17,14 @@ template <typename Node> inline bool test_node_name_value(const Node& node, cons return test_string_equal(node.name(), name) && test_string_equal(node.value(), value);
}
+inline bool test_node(const pugi::xml_node& node, const char* contents)
+{
+ std::ostringstream oss;
+ node.print(oss, "", pugi::format_raw);
+
+ return oss.str() == contents;
+}
+
struct test_runner
{
test_runner(const char* name)
@@ -73,5 +84,6 @@ struct dummy_fixture {}; #define CHECK_STRING(value, expected) if (test_string_equal(value, expected)) ; else throw #value " is not equal to " #expected
#define CHECK_DOUBLE(value, expected) if (fabs(value - expected) < 1e-6) ; else throw #value " is not equal to " #expected
#define CHECK_NAME_VALUE(node, name, value) if (test_node_name_value(node, name, value)) ; else throw #node " name/value do not match " #name " and " #value
+#define CHECK_NODE(node, expected) if (test_node(node, expected)) ; else throw #node " contents does not match " #expected
#endif
|