From b6433db22642307330311c42fffb6950287415df Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Sun, 11 Oct 2009 10:24:12 +0000 Subject: tests: Initial tree modification tests git-svn-id: http://pugixml.googlecode.com/svn/trunk@148 99668b35-9821-0410-8761-19e4c4f06640 --- tests/test.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/test.hpp') 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 #include +#include + +#include "../src/pugixml.hpp" inline bool test_string_equal(const char* lhs, const char* rhs) { @@ -14,6 +17,14 @@ template 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 -- cgit v1.2.3