mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-07-12 15:10:22 +08:00
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()
This commit is contained in:
@ -316,9 +316,9 @@ TEST(LeakDetection, DetectsLeak)
|
|||||||
UnityMalloc_EndTest();
|
UnityMalloc_EndTest();
|
||||||
EXPECT_ABORT_END
|
EXPECT_ABORT_END
|
||||||
UnityOutputCharSpy_Enable(0);
|
UnityOutputCharSpy_Enable(0);
|
||||||
|
Unity.CurrentTestFailed = 0;
|
||||||
CHECK(strstr(UnityOutputCharSpy_Get(), "This test leaks!"));
|
CHECK(strstr(UnityOutputCharSpy_Get(), "This test leaks!"));
|
||||||
free(m);
|
free(m);
|
||||||
Unity.CurrentTestFailed = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(LeakDetection, BufferOverrunFoundDuringFree)
|
TEST(LeakDetection, BufferOverrunFoundDuringFree)
|
||||||
@ -331,8 +331,8 @@ TEST(LeakDetection, BufferOverrunFoundDuringFree)
|
|||||||
free(m);
|
free(m);
|
||||||
EXPECT_ABORT_END
|
EXPECT_ABORT_END
|
||||||
UnityOutputCharSpy_Enable(0);
|
UnityOutputCharSpy_Enable(0);
|
||||||
CHECK(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during free()"));
|
|
||||||
Unity.CurrentTestFailed = 0;
|
Unity.CurrentTestFailed = 0;
|
||||||
|
CHECK(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during free()"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(LeakDetection, BufferOverrunFoundDuringRealloc)
|
TEST(LeakDetection, BufferOverrunFoundDuringRealloc)
|
||||||
@ -345,6 +345,6 @@ TEST(LeakDetection, BufferOverrunFoundDuringRealloc)
|
|||||||
m = realloc(m, 100);
|
m = realloc(m, 100);
|
||||||
EXPECT_ABORT_END
|
EXPECT_ABORT_END
|
||||||
UnityOutputCharSpy_Enable(0);
|
UnityOutputCharSpy_Enable(0);
|
||||||
CHECK(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during realloc()"));
|
|
||||||
Unity.CurrentTestFailed = 0;
|
Unity.CurrentTestFailed = 0;
|
||||||
|
CHECK(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during realloc()"));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user