From fc602fd37554f5e2d58fcee71a58e380d23d22d4 Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Thu, 29 Oct 2009 07:17:30 +0000 Subject: tests: Supported all pugixml compilation modes git-svn-id: http://pugixml.googlecode.com/svn/trunk@191 99668b35-9821-0410-8761-19e4c4f06640 --- tests/main.cpp | 60 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 26 deletions(-) (limited to 'tests/main.cpp') diff --git a/tests/main.cpp b/tests/main.cpp index 1886412..a1149ef 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -46,6 +46,35 @@ static void replace_memory_management() pugi::set_memory_management_functions(custom_allocate, custom_deallocate); } +static bool run_test(test_runner* test) +{ + try + { + g_memory_total_size = 0; + test_runner::_memory_fail_threshold = 0; + + test->run(); + + if (g_memory_total_size != 0) throw "Memory leaks found"; + + return true; + } + 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); + } + + return false; +} + int main() { replace_memory_management(); @@ -53,33 +82,12 @@ int main() unsigned int total = 0; unsigned int passed = 0; - for (test_runner* test = test_runner::_tests; test; test = test->_next) + test_runner* test = 0; // gcc3 "variable might be used uninitialized in this function" bug workaround + + for (test = test_runner::_tests; test; test = test->_next) { - try - { - total++; - - g_memory_total_size = 0; - test_runner::_memory_fail_threshold = 0; - - test->run(); - - if (g_memory_total_size != 0) throw "Memory leaks found"; - - 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); - } + total++; + passed += run_test(test); } unsigned int failed = total - passed; -- cgit v1.2.3