TestZlib.cpp 787 B

12345678910111213141516171819202122232425
  1. /*
  2. * Copyright (c) 2020-2021, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibTest/TestCase.h>
  7. #include <AK/Array.h>
  8. #include <LibCompress/Zlib.h>
  9. TEST_CASE(zlib_decompress_simple)
  10. {
  11. const Array<u8, 40> compressed {
  12. 0x78, 0x01, 0x01, 0x1D, 0x00, 0xE2, 0xFF, 0x54, 0x68, 0x69, 0x73, 0x20,
  13. 0x69, 0x73, 0x20, 0x61, 0x20, 0x73, 0x69, 0x6D, 0x70, 0x6C, 0x65, 0x20,
  14. 0x74, 0x65, 0x78, 0x74, 0x20, 0x66, 0x69, 0x6C, 0x65, 0x20, 0x3A, 0x29,
  15. 0x99, 0x5E, 0x09, 0xE8
  16. };
  17. const u8 uncompressed[] = "This is a simple text file :)";
  18. const auto decompressed = Compress::Zlib::decompress_all(compressed);
  19. EXPECT(decompressed.value().bytes() == (ReadonlyBytes { uncompressed, sizeof(uncompressed) - 1 }));
  20. }