summaryrefslogtreecommitdiff
path: root/tests/main.cpp
diff options
context:
space:
mode:
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;
}