diff options
author | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-10-29 07:17:30 +0000 |
---|---|---|
committer | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-10-29 07:17:30 +0000 |
commit | fc602fd37554f5e2d58fcee71a58e380d23d22d4 (patch) | |
tree | 2955c7999c2053c06a81c21a79fd55670bb6940e /tests/main.cpp | |
parent | 0640f87859a5a676b41783be4741a62f4d1ea266 (diff) |
tests: Supported all pugixml compilation modes
git-svn-id: http://pugixml.googlecode.com/svn/trunk@191 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/main.cpp')
-rw-r--r-- | tests/main.cpp | 60 |
1 files changed, 34 insertions, 26 deletions
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;
|