summaryrefslogtreecommitdiff
path: root/tests/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/main.cpp')
-rw-r--r--tests/main.cpp9
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));