test/src/runtime/wasm_memory_test.cpp
TEST_F(MemoryHeapTest, AllocateAfterDeallocate) {
  // two memory sizes totalling to the total memory size
  const size_t size1 = 2045;
  const size_t size2 = 2049;

  // allocate two memory chunks with total size equal to the memory size
  auto ptr1 = memory_.allocate(size1);
  memory_.allocate(size2);

  // deallocate first memory chunk
  memory_.deallocate(ptr1);

  // allocate new memory chunk
  auto ptr1_1 = memory_.allocate(size1);
  // expected that it will be allocated on the same place as the first memory
  // chunk that was deallocated
  ASSERT_EQ(ptr1, ptr1_1);
}
/**
 * @given memory with two memory chunk filling entire memory
 * @when first memory chunk of size size1 is deallocated @and new memory chunk
 * of the same size is trying to be allocated on that memory
 * @then it is allocated on the place of the first memory chunk
 */
@given memory with two memory chunk filling entire memory
@when first memory chunk of size size1 is deallocated @and new memory chunk
of the same size is trying to be allocated on that memory
@then it is allocated on the place of the first memory chunk
@given memory with two memory chunk filling entire memory @when first memory chunk of size size1 is deallocated @and new memory chunk of the same size is trying to be allocated on that memory @then it is allocated on the place of the first memory chunk
TEST_F(MemoryHeapTest, AllocateAfterDeallocate) {
  const size_t size1 = 2045;
  const size_t size2 = 2049;
  auto ptr1 = memory_.allocate(size1);
  memory_.allocate(size2);
  memory_.deallocate(ptr1);
  auto ptr1_1 = memory_.allocate(size1);
  ASSERT_EQ(ptr1, ptr1_1);
}
TEST_F ( MemoryHeapTest , AllocateAfterDeallocate ) { const size_t size1 = 2045 ; const size_t size2 = 2049 ; auto ptr1 = memory_ . allocate ( size1 ) ; memory_ . allocate ( size2 ) ; memory_ . deallocate ( ptr1 ) ; auto ptr1_1 = memory_ . allocate ( size1 ) ; ASSERT_EQ ( ptr1 , ptr1_1 ) ; }
@given memory with two memory chunk filling entire memory
 @when first memory chunk of size size1 is deallocated @and new memory chunk
 of the same size is trying to be allocated on that memory
 @then it is allocated on the place of the first memory chunk
@given memory with two memory chunk filling entire memory @when first memory chunk of size size1 is deallocated @and new memory chunk of the same size is trying to be allocated on that memory @then it is allocated on the place of the first memory chunk
// two memory sizes totalling to the total memory size // allocate two memory chunks with total size equal to the memory size // deallocate first memory chunk // allocate new memory chunk // expected that it will be allocated on the same place as the first memory // chunk that was deallocated