| 681 | |
| 682 | template <typename ArrayFactory, typename ExportCheckFunc> |
| 683 | void TestWithArrayFactory(ArrayFactory&& factory, ExportCheckFunc&& check_func) { |
| 684 | auto orig_bytes = pool_->bytes_allocated(); |
| 685 | |
| 686 | std::shared_ptr<Array> arr; |
| 687 | ASSERT_OK_AND_ASSIGN(arr, ToResult(factory())); |
| 688 | ARROW_SCOPED_TRACE("type = ", arr->type()->ToString(), |
| 689 | ", array data = ", arr->ToString()); |
| 690 | const ArrayData& data = *arr->data(); // non-owning reference |
| 691 | struct ArrowArray c_export; |
| 692 | ASSERT_OK(ExportArray(*arr, &c_export)); |
| 693 | |
| 694 | ArrayExportGuard guard(&c_export); |
| 695 | auto new_bytes = pool_->bytes_allocated(); |
| 696 | ASSERT_GT(new_bytes, orig_bytes); |
| 697 | |
| 698 | // Release the shared_ptr<Array>, underlying data should be held alive |
| 699 | arr.reset(); |
| 700 | ASSERT_EQ(pool_->bytes_allocated(), new_bytes); |
| 701 | check_func(&c_export, data); |
| 702 | |
| 703 | // Release the ArrowArray, underlying data should be destroyed |
| 704 | guard.Release(); |
| 705 | ASSERT_EQ(pool_->bytes_allocated(), orig_bytes); |
| 706 | } |
| 707 | |
| 708 | template <typename ArrayFactory> |
| 709 | void TestNested(ArrayFactory&& factory) { |
nothing calls this directly
no test coverage detected