From 6db04f4320cd5d24ae625dbc1df5a8a71b93e51d Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Sat, 10 Oct 2009 21:36:03 +0000 Subject: 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 --- tests/main.cpp | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'tests/main.cpp') 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 +#include + +test_runner* test_runner::_tests = 0; int main() { - pugi::xml_document doc; - doc.load(""); - 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; } -- cgit v1.2.3