diff options
author | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-10-11 06:49:30 +0000 |
---|---|---|
committer | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-10-11 06:49:30 +0000 |
commit | e11a81455afb36f59d2ec08ca7ccd4c56d0691a6 (patch) | |
tree | 71eed7bc143e2d9f6d0832e0347e02ca888df647 /tests/test.hpp | |
parent | 6ff7e795752b0cfc3d85e447bab063667e786150 (diff) |
tests: Added more node/attribute tests
git-svn-id: http://pugixml.googlecode.com/svn/trunk@142 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test.hpp')
-rw-r--r-- | tests/test.hpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/test.hpp b/tests/test.hpp index 6b8878e..fa4ef1d 100644 --- a/tests/test.hpp +++ b/tests/test.hpp @@ -2,12 +2,18 @@ #define HEADER_TEST_HPP
#include <string.h>
+#include <math.h>
inline bool test_string_equal(const char* lhs, const char* rhs)
{
return (!lhs || !rhs) ? lhs == rhs : strcmp(lhs, rhs) == 0;
}
+template <typename Node> inline bool test_node_name_value(const Node& node, const char* name, const char* value)
+{
+ return test_string_equal(node.name(), name) && test_string_equal(node.value(), value);
+}
+
struct test_runner
{
test_runner(const char* name)
@@ -48,20 +54,24 @@ struct dummy_fixture {}; #define TEST(name) TEST_FIXTURE(name, dummy_fixture)
-#define TEST_XML(name, xml) \
+#define TEST_XML_FLAGS(name, xml, flags) \
struct test_fixture_##name \
{ \
pugi::xml_document doc; \
\
test_fixture_##name() \
{ \
- CHECK(doc.load(xml)); \
+ CHECK(doc.load(xml, flags)); \
} \
}; \
\
TEST_FIXTURE(name, test_fixture_##name)
+#define TEST_XML(name, xml) TEST_XML_FLAGS(name, xml, pugi::parse_default)
+
#define CHECK(condition) if (condition) ; else throw #condition " is false"
#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
#endif
|