| 41 | namespace io { |
| 42 | |
| 43 | void AssertFileContents(const std::string& path, const std::string& contents) { |
| 44 | ASSERT_OK_AND_ASSIGN(auto rf, ReadableFile::Open(path)); |
| 45 | ASSERT_OK_AND_ASSIGN(int64_t size, rf->GetSize()); |
| 46 | ASSERT_EQ(size, contents.size()); |
| 47 | |
| 48 | ASSERT_OK_AND_ASSIGN(auto actual_data, rf->Read(size)); |
| 49 | ASSERT_TRUE(actual_data->Equals(Buffer(contents))); |
| 50 | } |
| 51 | |
| 52 | bool FileExists(const std::string& path) { return std::ifstream(path.c_str()).good(); } |
| 53 |