1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 09:07:44 +00:00

Streams: Distinguish recoverable and fatal errors.

This commit is contained in:
asynts 2020-08-31 13:12:15 +02:00 committed by Andreas Kling
parent daeb2bdc60
commit 9ce4475907
9 changed files with 75 additions and 59 deletions

View file

@ -49,7 +49,7 @@ TEST_CASE(read_an_integer)
InputMemoryStream stream { { &expected, sizeof(expected) } };
stream >> actual;
EXPECT(!stream.has_error() && stream.eof());
EXPECT(!stream.has_any_error() && stream.eof());
EXPECT_EQ(expected, actual);
}
@ -60,15 +60,15 @@ TEST_CASE(recoverable_error)
InputMemoryStream stream { { &expected, sizeof(expected) } };
EXPECT(!stream.has_error() && !stream.eof());
EXPECT(!stream.has_any_error() && !stream.eof());
stream >> to_large_value;
EXPECT(stream.has_error() && !stream.eof());
EXPECT(stream.has_recoverable_error() && !stream.eof());
EXPECT(stream.handle_error());
EXPECT(!stream.has_error() && !stream.eof());
EXPECT(stream.handle_recoverable_error());
EXPECT(!stream.has_any_error() && !stream.eof());
stream >> actual;
EXPECT(!stream.has_error() && stream.eof());
EXPECT(!stream.has_any_error() && stream.eof());
EXPECT_EQ(expected, actual);
}
@ -79,7 +79,7 @@ TEST_CASE(chain_stream_operator)
InputMemoryStream stream { { expected, sizeof(expected) } };
stream >> actual[0] >> actual[1] >> actual[2] >> actual[3];
EXPECT(!stream.has_error() && stream.eof());
EXPECT(!stream.has_any_error() && stream.eof());
EXPECT(compare({ expected, sizeof(expected) }, { actual, sizeof(actual) }));
}
@ -95,17 +95,17 @@ TEST_CASE(seeking_slicing_offset)
InputMemoryStream stream { { input, sizeof(input) } };
stream >> Bytes { actual0, sizeof(actual0) };
EXPECT(!stream.has_error() && !stream.eof());
EXPECT(!stream.has_any_error() && !stream.eof());
EXPECT(compare({ expected0, sizeof(expected0) }, { actual0, sizeof(actual0) }));
stream.seek(4);
stream >> Bytes { actual1, sizeof(actual1) };
EXPECT(!stream.has_error() && stream.eof());
EXPECT(!stream.has_any_error() && stream.eof());
EXPECT(compare({ expected1, sizeof(expected1) }, { actual1, sizeof(actual1) }));
stream.seek(1);
stream >> Bytes { actual2, sizeof(actual2) };
EXPECT(!stream.has_error() && !stream.eof());
EXPECT(!stream.has_any_error() && !stream.eof());
EXPECT(compare({ expected2, sizeof(expected2) }, { actual2, sizeof(actual2) }));
}