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

Function AssertFileContents

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

Source from the content-addressed store, hash-verified

110}; // namespace
111
112void AssertFileContents(FileSystem* fs, const std::string& path,
113 const std::string& expected_data) {
114 ASSERT_OK_AND_ASSIGN(FileInfo info, fs->GetFileInfo(path));
115 ASSERT_EQ(info.type(), FileType::File) << "For path '" << path << "'";
116 ASSERT_EQ(info.size(), static_cast<int64_t>(expected_data.length()))
117 << "For path '" << path << "'";
118
119 ASSERT_OK_AND_ASSIGN(auto stream, fs->OpenInputStream(path));
120 ASSERT_OK_AND_ASSIGN(auto buffer, stream->Read(info.size()));
121 AssertBufferEqual(*buffer, expected_data);
122 // No data left in stream
123 ASSERT_OK_AND_ASSIGN(auto leftover, stream->Read(1));
124 ASSERT_EQ(leftover->size(), 0);
125
126 ASSERT_OK(stream->Close());
127}
128
129void CreateFile(FileSystem* fs, const std::string& path, const std::string& data) {
130 ASSERT_OK_AND_ASSIGN(auto stream, fs->OpenOutputStream(path));

Callers 8

TestMoveFileMethod · 0.70
TestMoveDirMethod · 0.70
TestCopyFileMethod · 0.70
TestCopyFilesMethod · 0.70
TestOpenOutputStreamMethod · 0.70
test_util.ccFile · 0.70
TestSpecialCharsMethod · 0.70
TestBucketFunction · 0.70

Calls 5

AssertBufferEqualFunction · 0.85
typeMethod · 0.45
sizeMethod · 0.45
lengthMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected