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

Method TestOpenInputStream

cpp/src/arrow/filesystem/test_util.cc:1044–1082  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1042}
1043
1044void GenericFileSystemTest::TestOpenInputStream(FileSystem* fs) {
1045 ASSERT_OK(fs->CreateDir("AB"));
1046 CreateFile(fs, "AB/abc", "some data");
1047
1048 std::shared_ptr<io::InputStream> stream;
1049 std::shared_ptr<Buffer> buffer;
1050 ASSERT_OK_AND_ASSIGN(stream, fs->OpenInputStream("AB/abc"));
1051 ASSERT_OK_AND_ASSIGN(auto metadata, stream->ReadMetadata());
1052 // XXX we cannot really test anything more about metadata...
1053 ASSERT_OK_AND_EQ(0, stream->Tell());
1054 ASSERT_OK_AND_ASSIGN(buffer, stream->Read(4));
1055 AssertBufferEqual(*buffer, "some");
1056 ASSERT_OK_AND_ASSIGN(buffer, stream->Read(6 /*Remaining + 1*/));
1057 AssertBufferEqual(*buffer, " data");
1058 ASSERT_OK_AND_ASSIGN(buffer, stream->Read(1));
1059 AssertBufferEqual(*buffer, "");
1060 ASSERT_OK_AND_EQ(9, stream->Tell());
1061 ASSERT_OK(stream->Close());
1062
1063 ASSERT_OK_AND_ASSIGN(stream, fs->OpenInputStream("AB/abc"));
1064 ASSERT_OK(stream->Advance(4));
1065 ASSERT_OK_AND_EQ(4, stream->Tell());
1066 ASSERT_OK_AND_ASSIGN(buffer, stream->Read(6 /*Remaining + 1*/));
1067 AssertBufferEqual(*buffer, " data");
1068 ASSERT_OK(stream->Close());
1069 ASSERT_RAISES(Invalid, stream->Read(1)); // Stream is closed
1070
1071 // Trailing slash rejected
1072 ASSERT_RAISES(IOError, fs->OpenInputStream("AB/abc/"));
1073
1074 // File does not exist
1075 AssertRaisesWithErrno(ENOENT, fs->OpenInputStream("AB/def"));
1076 AssertRaisesWithErrno(ENOENT, fs->OpenInputStream("def"));
1077
1078 // Cannot open directory
1079 if (!allow_read_dir_as_file()) {
1080 ASSERT_RAISES(IOError, fs->OpenInputStream("AB"));
1081 }
1082}
1083
1084void GenericFileSystemTest::TestOpenInputStreamWithFileInfo(FileSystem* fs) {
1085 ASSERT_OK(fs->CreateDir("AB"));

Callers

nothing calls this directly

Calls 11

CreateFileFunction · 0.85
AssertBufferEqualFunction · 0.85
AssertRaisesWithErrnoFunction · 0.85
allow_read_dir_as_fileFunction · 0.85
ASSERT_OK_AND_ASSIGNFunction · 0.70
CreateDirMethod · 0.45
OpenInputStreamMethod · 0.45
TellMethod · 0.45
ReadMethod · 0.45
CloseMethod · 0.45
AdvanceMethod · 0.45

Tested by

no test coverage detected