| 305 | } |
| 306 | |
| 307 | void TestReadError(const RecordWriterOptions& writer_options, |
| 308 | const RecordReaderOptions& reader_options) { |
| 309 | const string wrote = BigString("well hello there!", 100); |
| 310 | string contents; |
| 311 | StringDest dst(&contents); |
| 312 | TF_ASSERT_OK(RecordWriter(&dst, writer_options).WriteRecord(wrote)); |
| 313 | |
| 314 | StringSource file(&contents); |
| 315 | RecordReader reader(&file, reader_options); |
| 316 | |
| 317 | uint64 offset = 0; |
| 318 | string read; |
| 319 | file.force_error(); |
| 320 | Status status = reader.ReadRecord(&offset, &read); |
| 321 | ASSERT_TRUE(errors::IsDataLoss(status)); |
| 322 | ASSERT_EQ(0, offset); |
| 323 | |
| 324 | // A failed Read() shouldn't update the offset, and thus a retry shouldn't |
| 325 | // lose the record. |
| 326 | status = reader.ReadRecord(&offset, &read); |
| 327 | ASSERT_TRUE(status.ok()) << status; |
| 328 | EXPECT_GT(offset, 0); |
| 329 | EXPECT_EQ(wrote, read); |
| 330 | } |
| 331 | |
| 332 | TEST_F(RecordioTest, ReadError) { |
| 333 | TestReadError(RecordWriterOptions(), RecordReaderOptions()); |
no test coverage detected