--- a/tests/test_buffer.cpp Sun Apr 16 21:09:25 2023 +0200 +++ b/tests/test_buffer.cpp Sun Apr 16 21:35:08 2023 +0200 @@ -127,6 +127,24 @@ EXPECT_TRUE(alloc.verify()); } +TEST(BufferInit, OnHeap) { + CxTestingAllocator alloc; + CxBuffer *buf; + void *space = cxMalloc(&alloc, 16); + buf = cxBufferCreate(space, 16, &alloc, CX_BUFFER_FREE_CONTENTS); + EXPECT_NE(buf, nullptr); + expect_default_flush_config(buf); + EXPECT_EQ(buf->space, space); + EXPECT_EQ(buf->flags & CX_BUFFER_AUTO_EXTEND, 0); + EXPECT_EQ(buf->flags & CX_BUFFER_FREE_CONTENTS, CX_BUFFER_FREE_CONTENTS); + EXPECT_EQ(buf->pos, 0); + EXPECT_EQ(buf->size, 0); + EXPECT_EQ(buf->capacity, 16); + EXPECT_EQ(buf->allocator, &alloc); + cxBufferFree(buf); + EXPECT_TRUE(alloc.verify()); +} + class BufferShiftFixture : public ::testing::Test { protected: void SetUp() override {