| 62 | } |
| 63 | |
| 64 | TEST_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 | |
| 104 | TEST_F(TestExportArray, TestErrors) { |
| 105 | const std::shared_ptr<Array> array_null = ArrayFromJSON(null(), "[]"); |
nothing calls this directly
no test coverage detected