@@ -22,24 +22,23 @@ namespace test
2222
2323class O1HeapMemoryResourceTest : public ::testing::Test
2424{
25- static constexpr std::size_t TestBufferSize = 0x100000 ;
25+ static constexpr std::size_t TestBufferSize = 4096 ;
2626
27- public:
28- cetl::pmr::O1HeapAlignedStorage<TestBufferSize> large_buffer{};
27+ void SetUp () override
28+ {
29+ // Fill the buffer with a known pattern to help identify uninitialized memory usage
30+ memset (&large_buffer, 0xAA , sizeof (large_buffer)); // NOLINT
31+ }
32+
33+ protected:
34+ static cetl::pmr::O1HeapAlignedStorage<TestBufferSize> large_buffer;
2935};
3036
31- TEST_F (O1HeapMemoryResourceTest, TestDefault)
32- {
33- cetl::pmr::UnsynchronizedO1HeapMemoryResourceDelegate test_subject{large_buffer};
34- void * mem = test_subject.allocate (8 );
35- ASSERT_NE (nullptr , mem);
36- test_subject.deallocate (mem, 8 );
37- }
37+ cetl::pmr::O1HeapAlignedStorage<O1HeapMemoryResourceTest::TestBufferSize> O1HeapMemoryResourceTest::large_buffer;
3838
3939TEST_F (O1HeapMemoryResourceTest, O1HeapAlignedStorageTest)
4040{
41- cetl::pmr::O1HeapAlignedStorage<4096 > aligned_storage{};
42- cetl::pmr::UnsynchronizedO1HeapMemoryResourceDelegate test_subject{aligned_storage};
41+ cetl::pmr::UnsynchronizedO1HeapMemoryResourceDelegate test_subject{large_buffer};
4342 void * mem = test_subject.allocate (16 );
4443 ASSERT_NE (nullptr , mem);
4544 test_subject.deallocate (mem, 16 );
@@ -89,12 +88,7 @@ TEST_F(O1HeapMemoryResourceTest, TestAllocationFailureThrowsBadAlloc)
8988 void * final_alloc = test_subject.allocate (64 );
9089 EXPECT_EQ (nullptr , final_alloc) << " Allocation should return nullptr when heap is exhausted" ;
9190#endif
92-
93- // Clean up allocations
94- for (void * mem : allocations)
95- {
96- test_subject.deallocate (mem, 64 );
97- }
91+ // Don't worry about deallocating memory since the allocator and small_buffer both go out of scope with the test.
9892}
9993
10094} // namespace test
0 commit comments