MCPcopy Create free account
hub / github.com/apache/arrow / TestZeroSizeAllocateBuffer

Function TestZeroSizeAllocateBuffer

cpp/src/arrow/buffer_test.cc:635–657  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

633
634template <typename AllocateFunction>
635void TestZeroSizeAllocateBuffer(MemoryPool* pool, AllocateFunction&& allocate_func) {
636 auto allocated_bytes = pool->bytes_allocated();
637 {
638 std::shared_ptr<Buffer> buffer, buffer2;
639
640 ASSERT_OK(allocate_func(pool, 0, &buffer));
641 AssertIsCPUBuffer(*buffer);
642 ASSERT_EQ(buffer->size(), 0);
643 // Even 0-sized buffers should not have a null data pointer
644 auto data = buffer->data();
645 ASSERT_NE(data, nullptr);
646 ASSERT_EQ(buffer->mutable_data(), data);
647
648 // As an optimization, another 0-size buffer should share the same memory "area"
649 ASSERT_OK(allocate_func(pool, 0, &buffer2));
650 AssertIsCPUBuffer(*buffer2);
651 ASSERT_EQ(buffer2->size(), 0);
652 ASSERT_EQ(buffer2->data(), data);
653
654 ASSERT_GE(pool->bytes_allocated(), allocated_bytes);
655 }
656 ASSERT_EQ(pool->bytes_allocated(), allocated_bytes);
657}
658
659TEST(TestAllocateBuffer, ZeroSize) {
660 MemoryPool* pool = default_memory_pool();

Callers 1

TESTFunction · 0.85

Calls 5

AssertIsCPUBufferFunction · 0.85
bytes_allocatedMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
mutable_dataMethod · 0.45

Tested by

no test coverage detected