From c629e120e104623d7a3648f4f00f1702e55657df Mon Sep 17 00:00:00 2001 From: jsalling Date: Wed, 16 Dec 2015 17:21:09 -0600 Subject: [PATCH] Fix Leak Detection always passing, but printing a fail message Don't set CurrentTestFailed = 0 at end, move before last check These tests now fail if the output_Spy is not used instead of putchar() --- extras/fixture/test/unity_fixture_Test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extras/fixture/test/unity_fixture_Test.c b/extras/fixture/test/unity_fixture_Test.c index af70934..238be5f 100644 --- a/extras/fixture/test/unity_fixture_Test.c +++ b/extras/fixture/test/unity_fixture_Test.c @@ -316,9 +316,9 @@ TEST(LeakDetection, DetectsLeak) UnityMalloc_EndTest(); EXPECT_ABORT_END UnityOutputCharSpy_Enable(0); + Unity.CurrentTestFailed = 0; CHECK(strstr(UnityOutputCharSpy_Get(), "This test leaks!")); free(m); - Unity.CurrentTestFailed = 0; } TEST(LeakDetection, BufferOverrunFoundDuringFree) @@ -331,8 +331,8 @@ TEST(LeakDetection, BufferOverrunFoundDuringFree) free(m); EXPECT_ABORT_END UnityOutputCharSpy_Enable(0); - CHECK(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during free()")); Unity.CurrentTestFailed = 0; + CHECK(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during free()")); } TEST(LeakDetection, BufferOverrunFoundDuringRealloc) @@ -345,6 +345,6 @@ TEST(LeakDetection, BufferOverrunFoundDuringRealloc) m = realloc(m, 100); EXPECT_ABORT_END UnityOutputCharSpy_Enable(0); - CHECK(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during realloc()")); Unity.CurrentTestFailed = 0; + CHECK(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during realloc()")); } -- GitLab