pitrou commented on code in PR #14064:
URL: https://github.com/apache/arrow/pull/14064#discussion_r977269004
##########
cpp/src/arrow/filesystem/test_util.cc:
##########
@@ -1056,8 +1064,21 @@ void
GenericFileSystemTest::TestOpenInputFile(FileSystem* fs) {
std::shared_ptr<io::RandomAccessFile> file;
std::shared_ptr<Buffer> buffer;
ASSERT_OK_AND_ASSIGN(file, fs->OpenInputFile("AB/abc"));
- ASSERT_OK_AND_ASSIGN(buffer, file->ReadAt(5, 6));
+ ASSERT_OK_AND_EQ(0, file->Tell());
+ ASSERT_OK(file->Seek(10));
+ ASSERT_OK_AND_EQ(10, file->Tell());
+ ASSERT_OK_AND_ASSIGN(buffer, file->Read(6 /*Remaining + 1*/));
+ AssertBufferEqual(*buffer, " data");
+ ASSERT_OK_AND_ASSIGN(buffer, file->Read(1));
+ AssertBufferEqual(*buffer, "");
+ ASSERT_OK_AND_EQ(15, file->Tell());
+ ASSERT_OK(file->Seek(5));
+ ASSERT_OK_AND_EQ(5, file->Tell());
+ ASSERT_OK_AND_ASSIGN(buffer, file->Read(6));
AssertBufferEqual(*buffer, "other ");
+ // Should return the same slice independent of the current position
+ ASSERT_OK_AND_ASSIGN(buffer, file->ReadAt(0, 4));
Review Comment:
Would be nice to test with a non-zero start pos here.
##########
cpp/src/arrow/filesystem/test_util.cc:
##########
@@ -971,12 +971,20 @@ void
GenericFileSystemTest::TestOpenInputStream(FileSystem* fs) {
ASSERT_OK_AND_ASSIGN(stream, fs->OpenInputStream("AB/abc"));
ASSERT_OK_AND_ASSIGN(auto metadata, stream->ReadMetadata());
// XXX we cannot really test anything more about metadata...
+ ASSERT_OK_AND_EQ(0, stream->Tell());
ASSERT_OK_AND_ASSIGN(buffer, stream->Read(4));
AssertBufferEqual(*buffer, "some");
- ASSERT_OK_AND_ASSIGN(buffer, stream->Read(6));
+ ASSERT_OK_AND_ASSIGN(buffer, stream->Read(6 /*Remaining + 1*/));
AssertBufferEqual(*buffer, " data");
ASSERT_OK_AND_ASSIGN(buffer, stream->Read(1));
AssertBufferEqual(*buffer, "");
+ ASSERT_OK_AND_EQ(9, stream->Tell());
Review Comment:
Nit: close the stream after this?
--
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]