summaryrefslogtreecommitdiff
path: root/tests/main.cpp
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2009-10-10 21:36:03 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2009-10-10 21:36:03 +0000
commit6db04f4320cd5d24ae625dbc1df5a8a71b93e51d (patch)
treee6e5c79464b4d4c05c75fd6dbb8f4d3e800edbcc /tests/main.cpp
parentab28c3b45e611b5d49a03024bd6ae7b184d37d4a (diff)
tests: Added simple test framework, added a couple of tests
git-svn-id: http://pugixml.googlecode.com/svn/trunk@140 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/main.cpp')
-rw-r--r--tests/main.cpp43
1 files changed, 38 insertions, 5 deletions
diff --git a/tests/main.cpp b/tests/main.cpp
index ab3187c..55903b9 100644
--- a/tests/main.cpp
+++ b/tests/main.cpp
@@ -1,10 +1,43 @@
-#include "../src/pugixml.hpp"
+#include "test.hpp"
+
+#include <exception>
+#include <stdio.h>
+
+test_runner* test_runner::_tests = 0;
int main()
{
- pugi::xml_document doc;
- doc.load("<node/>");
- doc.select_single_node("node");
+ unsigned int total = 0;
+ unsigned int passed = 0;
+
+ for (test_runner* test = test_runner::_tests; test; test = test->_next)
+ {
+ try
+ {
+ total++;
+ test->run();
+ passed++;
+ }
+ catch (const std::exception& e)
+ {
+ printf("Test %s failed: exception %s\n", test->_name, e.what());
+ }
+ catch (const char* e)
+ {
+ printf("Test %s failed: %s\n", test->_name, e);
+ }
+ catch (...)
+ {
+ printf("Test %s failed for unknown reason\n", test->_name);
+ }
+ }
+
+ unsigned int failed = total - passed;
+
+ if (failed != 0)
+ printf("FAILURE: %u out of %u tests failed.\n", failed, total);
+ else
+ printf("Success: %d tests passed.\n", total);
- // doc.select_single_node("//"); - fails? why? :)
+ return failed;
}