diff options
author | Tim Schumacher <timschumi@gmx.de> | 2023-04-05 20:26:10 +0200 |
---|---|---|
committer | Jelle Raaijmakers <jelle@gmta.nl> | 2023-04-09 18:27:06 +0200 |
commit | d4e48db1e18b3e30eb00f7272a7843586e2931fb (patch) | |
tree | 2e9721120508196bd1e5350d9258dc9ac1324f38 | |
parent | 5f806ec53acf8e7127c07961e42f6c1585fe9129 (diff) | |
download | serenity-d4e48db1e18b3e30eb00f7272a7843586e2931fb.zip |
Tests: Convert LZMA and XZ tests to `TRY_OR_FAIL`
This is very useful for tracking down a breakage without having to add
temporary dbgln manually.
-rw-r--r-- | Tests/LibCompress/TestLzma.cpp | 8 | ||||
-rw-r--r-- | Tests/LibCompress/TestXz.cpp | 38 |
2 files changed, 23 insertions, 23 deletions
diff --git a/Tests/LibCompress/TestLzma.cpp b/Tests/LibCompress/TestLzma.cpp index 6007d6c8ac..79afae9b2f 100644 --- a/Tests/LibCompress/TestLzma.cpp +++ b/Tests/LibCompress/TestLzma.cpp @@ -51,7 +51,7 @@ TEST_CASE(specification_a_lzma_decompress) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::LzmaDecompressor::create_from_container(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(specification_a_txt, buffer.span()); } @@ -70,7 +70,7 @@ TEST_CASE(specification_a_eos_lzma_decompress) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::LzmaDecompressor::create_from_container(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(specification_a_txt, buffer.span()); } @@ -89,7 +89,7 @@ TEST_CASE(specification_a_eos_and_size_lzma_decompress) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::LzmaDecompressor::create_from_container(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(specification_a_txt, buffer.span()); } @@ -109,7 +109,7 @@ TEST_CASE(specification_a_lp1_lc2_pb1_lzma_decompress) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::LzmaDecompressor::create_from_container(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(specification_a_txt, buffer.span()); } diff --git a/Tests/LibCompress/TestXz.cpp b/Tests/LibCompress/TestXz.cpp index 83142ab38f..4f4ca826a4 100644 --- a/Tests/LibCompress/TestXz.cpp +++ b/Tests/LibCompress/TestXz.cpp @@ -64,7 +64,7 @@ TEST_CASE(lzma2_compressed_without_settings_after_uncompressed) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ("\x00\x00\x00"sv.bytes(), buffer.span()); } @@ -174,7 +174,7 @@ TEST_CASE(lzma2_literal_context_bits_after_state_reset) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ("\x80\x80\x80"sv.bytes(), buffer.span()); } @@ -1090,7 +1090,7 @@ TEST_CASE(xz_utils_good_0cat_empty) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(buffer.size(), 0ul); } @@ -1108,7 +1108,7 @@ TEST_CASE(xz_utils_good_0catpad_empty) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(buffer.size(), 0ul); } @@ -1122,7 +1122,7 @@ TEST_CASE(xz_utils_good_0_empty) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(buffer.size(), 0ul); } @@ -1138,7 +1138,7 @@ TEST_CASE(xz_utils_good_0pad_empty) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(buffer.size(), 0ul); } @@ -1332,7 +1332,7 @@ TEST_CASE(xz_utils_good_1_block_header_1) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(buffer.span(), xz_utils_hello_world.bytes()); } @@ -1349,7 +1349,7 @@ TEST_CASE(xz_utils_good_1_block_header_2) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(buffer.span(), xz_utils_hello_world.bytes()); } @@ -1366,7 +1366,7 @@ TEST_CASE(xz_utils_good_1_block_header_3) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(buffer.span(), xz_utils_hello_world.bytes()); } @@ -1384,7 +1384,7 @@ TEST_CASE(xz_utils_good_1_check_crc32) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(buffer.span(), xz_utils_hello_world.bytes()); } @@ -1401,7 +1401,7 @@ TEST_CASE(xz_utils_good_1_check_crc64) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(buffer.span(), xz_utils_hello_world.bytes()); } @@ -1418,7 +1418,7 @@ TEST_CASE(xz_utils_good_1_check_none) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(buffer.span(), xz_utils_hello_world.bytes()); } @@ -1437,7 +1437,7 @@ TEST_CASE(xz_utils_good_1_check_sha256) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(buffer.span(), xz_utils_hello_world.bytes()); } @@ -1498,7 +1498,7 @@ TEST_CASE(xz_utils_good_1_lzma2_1) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(buffer.span(), xz_utils_lorem_ipsum.bytes()); } @@ -1538,7 +1538,7 @@ TEST_CASE(xz_utils_good_1_lzma2_2) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(buffer.span(), xz_utils_lorem_ipsum.bytes()); } @@ -1578,7 +1578,7 @@ TEST_CASE(xz_utils_good_1_lzma2_3) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(buffer.span(), xz_utils_lorem_ipsum.bytes()); } @@ -1621,7 +1621,7 @@ TEST_CASE(xz_utils_good_1_lzma2_4) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(buffer.span(), xz_utils_lorem_ipsum.bytes()); } @@ -1639,7 +1639,7 @@ TEST_CASE(xz_utils_good_1_lzma2_5) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(buffer.size(), 0ul); } @@ -1770,7 +1770,7 @@ TEST_CASE(xz_utils_good_2_lzma2) auto stream = MUST(try_make<FixedMemoryStream>(compressed)); auto decompressor = MUST(Compress::XzDecompressor::create(move(stream))); - auto buffer = MUST(decompressor->read_until_eof(PAGE_SIZE)); + auto buffer = TRY_OR_FAIL(decompressor->read_until_eof(PAGE_SIZE)); EXPECT_EQ(buffer.span(), xz_utils_hello_world.bytes()); } |