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

Function TEST_F

cpp/src/arrow/c/dlpack_test.cc:64–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64TEST_F(TestExportArray, TestSupportedArray) {
65 const std::vector<std::pair<std::shared_ptr<DataType>, DLDataTypeCode>> cases = {
66 {int8(), DLDataTypeCode::kDLInt},
67 {uint8(), DLDataTypeCode::kDLUInt},
68 {
69 int16(),
70 DLDataTypeCode::kDLInt,
71 },
72 {uint16(), DLDataTypeCode::kDLUInt},
73 {
74 int32(),
75 DLDataTypeCode::kDLInt,
76 },
77 {uint32(), DLDataTypeCode::kDLUInt},
78 {
79 int64(),
80 DLDataTypeCode::kDLInt,
81 },
82 {uint64(), DLDataTypeCode::kDLUInt},
83 {float16(), DLDataTypeCode::kDLFloat},
84 {float32(), DLDataTypeCode::kDLFloat},
85 {float64(), DLDataTypeCode::kDLFloat}};
86
87 const auto allocated_bytes = arrow::default_memory_pool()->bytes_allocated();
88
89 for (auto [arrow_type, dlpack_type] : cases) {
90 const std::shared_ptr<Array> array =
91 ArrayFromJSON(arrow_type, "[1, 0, 10, 0, 2, 1, 3, 5, 1, 0]");
92 CheckDLTensor(array, arrow_type, dlpack_type, 10);
93 ASSERT_OK_AND_ASSIGN(auto sliced_1, array->SliceSafe(1, 5));
94 CheckDLTensor(sliced_1, arrow_type, dlpack_type, 5);
95 ASSERT_OK_AND_ASSIGN(auto sliced_2, array->SliceSafe(0, 5));
96 CheckDLTensor(sliced_2, arrow_type, dlpack_type, 5);
97 ASSERT_OK_AND_ASSIGN(auto sliced_3, array->SliceSafe(3));
98 CheckDLTensor(sliced_3, arrow_type, dlpack_type, 7);
99 }
100
101 ASSERT_EQ(allocated_bytes, arrow::default_memory_pool()->bytes_allocated());
102}
103
104TEST_F(TestExportArray, TestErrors) {
105 const std::shared_ptr<Array> array_null = ArrayFromJSON(null(), "[]");

Callers

nothing calls this directly

Calls 9

default_memory_poolFunction · 0.85
ArrayFromJSONFunction · 0.85
CheckDLTensorFunction · 0.85
ExportDeviceFunction · 0.85
TensorFromJSONFunction · 0.85
ExportArrayFunction · 0.70
bytes_allocatedMethod · 0.45
ToStringMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected