1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:07:35 +00:00

Tests: Prefer TRY_OR_FAIL() and MUST() over EXPECT(!.is_error())

Note that in some cases (in particular SQL::Result and PDFErrorOr),
there is no Formatter defined for the error type, hence TRY_OR_FAIL
cannot work as-is. Furthermore, this commit leaves untouched the places
where MUST could be replaced by TRY_OR_FAIL.

Inspired by:
https://github.com/SerenityOS/serenity/pull/18710#discussion_r1186892445
This commit is contained in:
Ben Wiederhake 2023-05-07 20:14:06 +02:00 committed by Andrew Kaster
parent 87a7299078
commit f890b70eae
23 changed files with 415 additions and 742 deletions

View file

@ -89,11 +89,9 @@ TEST_CASE(gzip_round_trip)
{
auto original = ByteBuffer::create_uninitialized(1024).release_value();
fill_with_random(original);
auto compressed = Compress::GzipCompressor::compress_all(original);
EXPECT(!compressed.is_error());
auto uncompressed = Compress::GzipDecompressor::decompress_all(compressed.value());
EXPECT(!uncompressed.is_error());
EXPECT(uncompressed.value() == original);
auto compressed = TRY_OR_FAIL(Compress::GzipCompressor::compress_all(original));
auto uncompressed = TRY_OR_FAIL(Compress::GzipDecompressor::decompress_all(compressed));
EXPECT(uncompressed == original);
}
TEST_CASE(gzip_truncated_uncompressed_block)