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

Method TestOpenInputFile

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

Source from the content-addressed store, hash-verified

1138}
1139
1140void GenericFileSystemTest::TestOpenInputFile(FileSystem* fs) {
1141 ASSERT_OK(fs->CreateDir("AB"));
1142 CreateFile(fs, "AB/abc", "some other data");
1143
1144 std::shared_ptr<io::RandomAccessFile> file;
1145 std::shared_ptr<Buffer> buffer;
1146 ASSERT_OK_AND_ASSIGN(file, fs->OpenInputFile("AB/abc"));
1147 ASSERT_OK_AND_EQ(0, file->Tell());
1148 ASSERT_OK(file->Seek(10));
1149 ASSERT_OK_AND_EQ(10, file->Tell());
1150 ASSERT_OK_AND_ASSIGN(buffer, file->Read(6 /*Remaining + 1*/));
1151 AssertBufferEqual(*buffer, " data");
1152 ASSERT_OK_AND_ASSIGN(buffer, file->Read(1));
1153 AssertBufferEqual(*buffer, "");
1154 ASSERT_OK_AND_EQ(15, file->Tell());
1155 ASSERT_OK(file->Seek(5));
1156 ASSERT_OK_AND_EQ(5, file->Tell());
1157 ASSERT_OK_AND_ASSIGN(buffer, file->Read(6));
1158 AssertBufferEqual(*buffer, "other ");
1159 // Should return the same slice independent of the current position
1160 ASSERT_OK_AND_ASSIGN(buffer, file->ReadAt(2, 3));
1161 AssertBufferEqual(*buffer, "me ");
1162 ASSERT_OK_AND_EQ(15, file->GetSize());
1163 ASSERT_OK(file->Close());
1164 ASSERT_RAISES(Invalid, file->ReadAt(1, 1)); // Stream is closed
1165
1166 // Trailing slash rejected
1167 ASSERT_RAISES(IOError, fs->OpenInputFile("AB/abc/"));
1168
1169 // File does not exist
1170 AssertRaisesWithErrno(ENOENT, fs->OpenInputFile("AB/def"));
1171 AssertRaisesWithErrno(ENOENT, fs->OpenInputFile("def"));
1172
1173 // Cannot open directory
1174 if (!allow_read_dir_as_file()) {
1175 ASSERT_RAISES(IOError, fs->OpenInputFile("AB"));
1176 }
1177}
1178
1179void GenericFileSystemTest::TestOpenInputFileAsync(FileSystem* fs) {
1180 ASSERT_OK(fs->CreateDir("AB"));

Callers

nothing calls this directly

Calls 13

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
OpenInputFileMethod · 0.45
TellMethod · 0.45
SeekMethod · 0.45
ReadMethod · 0.45
ReadAtMethod · 0.45
GetSizeMethod · 0.45

Tested by

no test coverage detected