diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-04-12 03:05:58 -0700 |
---|---|---|
committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-04-12 03:05:58 -0700 |
commit | a19da1c246f244da57197915df3ab70f24bf1502 (patch) | |
tree | 08522294870adb468c37042365095ebbae2c0177 /tests/main.cpp | |
parent | e90d2ac8ba44fbcf4d5702643f708f2c86bde42e (diff) | |
parent | a0d065cd22d1d43c417f6d3db88a04bf57b67ed0 (diff) |
Merge branch 'master' into compact
Diffstat (limited to 'tests/main.cpp')
-rw-r--r-- | tests/main.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/main.cpp b/tests/main.cpp index c4c9341..6996eb9 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -27,11 +27,13 @@ const char* test_runner::_temp_path; static size_t g_memory_total_size = 0; static size_t g_memory_total_count = 0; +static size_t g_memory_fail_triggered = false; static void* custom_allocate(size_t size) { if (test_runner::_memory_fail_threshold > 0 && test_runner::_memory_fail_threshold < g_memory_total_size + size) { + g_memory_fail_triggered = true; test_runner::_memory_fail_triggered = true; return 0; @@ -88,6 +90,7 @@ static bool run_test(test_runner* test) #endif g_memory_total_size = 0; g_memory_total_count = 0; + g_memory_fail_triggered = false; test_runner::_memory_fail_threshold = 0; test_runner::_memory_fail_triggered = false; @@ -113,6 +116,12 @@ static bool run_test(test_runner* test) test->run(); + if (test_runner::_memory_fail_triggered) + { + printf("Test %s failed: unguarded memory fail triggered\n", test->_name); + return false; + } + if (g_memory_total_size != 0 || g_memory_total_count != 0) { printf("Test %s failed: memory leaks found (%u bytes in %u allocations)\n", test->_name, static_cast<unsigned int>(g_memory_total_size), static_cast<unsigned int>(g_memory_total_count)); |