dkp116 commented on code in PR #50366:
URL: https://github.com/apache/arrow/pull/50366#discussion_r3532311607
##########
cpp/src/arrow/array/array_test.cc:
##########
@@ -1137,7 +1137,39 @@ TEST_F(TestArray, TestBinaryViewAppendArraySlice) {
AssertArraysEqual(*src, *dst);
}
-
+TEST_F(TestArray, GetSpanRespectsOffset) {
+ auto data_buffer = Buffer::FromString("123456789abcdef0");
+ auto data = ArrayData::Make(uint8(), 3, {nullptr, data_buffer}, 0, 1);
+ auto span = data->GetSpan<uint8_t>(1, 3);
+
+ EXPECT_EQ(span.size(), 3);
+ EXPECT_EQ(span[0], '2');
+ EXPECT_EQ(span[1], '3');
+ EXPECT_EQ(span[2], '4');
+}
+TEST_F(TestArray, GetMutableSpanRespectsOffset) {
+ const int64_t nbytes = 16;
+ ASSERT_OK_AND_ASSIGN(auto uniq_buffer, AllocateResizableBuffer(nbytes,
pool_));
+ memset(uniq_buffer->mutable_data(), '0', nbytes);
+ std::shared_ptr<Buffer> buffer(std::move(uniq_buffer));
+ std::vector<std::shared_ptr<Buffer>> buffers = {nullptr, buffer};
+ auto data = ArrayData::Make(uint8(), 3, buffers, 0, 1);
+ auto span = data->template GetMutableSpan<uint8_t>(1, 3);
Review Comment:
Hi @pitrou, thank you for reviewing, I have amended the tests and formatting
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]