From 513db7130b9ac2a0930145904257f262d648f745 Mon Sep 17 00:00:00 2001 From: Kearwood Gilbert Date: Sun, 20 Sep 2026 14:19:07 -0700 Subject: [PATCH] Add tests for Heap allocator --- tests/heap_test.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/heap_test.cpp diff --git a/tests/heap_test.cpp b/tests/heap_test.cpp new file mode 100644 index 0000000..3204fa0 --- /dev/null +++ b/tests/heap_test.cpp @@ -0,0 +1,23 @@ +#include +#include "mimir.h" + +#include "test_util.h" + +namespace mimir_tests { + +TEST(Heap, InitialState) +{ + mimir::init(); + mimir::Heap heap; + EXPECT_EQ(heap.getUsed(), 0); +} + +TEST(Heap, OutOfMemory) +{ + mimir::init(); + mimir::Heap heap; + EXPECT_TRUE(heap.init(1ULL << 24, 1ULL << 46)); + EXPECT_TRUE(heap.alloc(1ULL << 49) == nullptr); +} + +}; // namespace mimir_tests