diff --git a/extras/fixture/test/unity_fixture_Test.c b/extras/fixture/test/unity_fixture_Test.c index 472ffb1a522217c041f0358525a754391d9e9148..3f2d32feaf57988ee016b36e336e10f5507e4664 100644 --- a/extras/fixture/test/unity_fixture_Test.c +++ b/extras/fixture/test/unity_fixture_Test.c @@ -479,6 +479,10 @@ TEST(LeakDetection, PointerSettingMax) //------------------------------------------------------------ TEST_GROUP(InternalMalloc); +#define TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(first_mem_ptr, ptr) \ + ptr = malloc(10); free(ptr); \ + TEST_ASSERT_EQUAL_PTR_MESSAGE(first_mem_ptr, ptr, "Memory was stranded, free in LIFO order"); + TEST_SETUP(InternalMalloc) { } TEST_TEAR_DOWN(InternalMalloc) { } @@ -491,6 +495,7 @@ TEST(InternalMalloc, MallocPastBufferFails) free(m); TEST_ASSERT_NOT_NULL(m); TEST_ASSERT_NULL(n); + TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(m, n); #endif } @@ -502,6 +507,7 @@ TEST(InternalMalloc, CallocPastBufferFails) free(m); TEST_ASSERT_NOT_NULL(m); TEST_ASSERT_NULL(n); + TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(m, n); #endif } @@ -513,6 +519,7 @@ TEST(InternalMalloc, MallocThenReallocGrowsMemoryInPlace) free(n); TEST_ASSERT_NOT_NULL(m); TEST_ASSERT_EQUAL(m, n); + TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(m, n); #endif } @@ -523,6 +530,7 @@ TEST(InternalMalloc, ReallocFailDoesNotFreeMem) void* n1 = malloc(10); void* out_of_mem = realloc(n1, UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 1); void* n2 = malloc(10); + free(n2); if (out_of_mem == NULL) free(n1); free(m); @@ -530,5 +538,6 @@ TEST(InternalMalloc, ReallocFailDoesNotFreeMem) TEST_ASSERT_NOT_NULL(m); // Got a real memory location TEST_ASSERT_NULL(out_of_mem); // The realloc should have failed TEST_ASSERT_NOT_EQUAL(n2, n1); // If n1 != n2 then realloc did not free n1 + TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(m, n2); #endif }