diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2025-09-10 22:12:22 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2025-09-10 22:12:22 +0200 |
| commit | 32e14551a90e85000e41b3f0445d34d58a1431e4 (patch) | |
| tree | 912c1e50b93b501446b1b179ee2a3e93586fb854 /test/decompress.cc | |
| parent | cf99d0c865474105c14b2348fdbd1c83d87d5a29 (diff) | |
Add unicode general category lookup
Generate the lookup tables from UnicodeData.txt, do to that,
add gen_ugc, which uses csv, buffers, line, io and other modules
to do the job.
Diffstat (limited to 'test/decompress.cc')
| -rw-r--r-- | test/decompress.cc | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/test/decompress.cc b/test/decompress.cc new file mode 100644 index 0000000..35c4477 --- /dev/null +++ b/test/decompress.cc @@ -0,0 +1,72 @@ +#include <gtest/gtest.h> + +#include "decompress.hh" + +TEST(z_decompress, empty) { + static const unsigned char data[] = { + 0x1f, 0x8b, 0x08, 0x08, 0x33, 0xd4, 0xbd, 0x68, + 0x02, 0x03, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00 + }; + auto reader = decompress::gzip(io::memory(std::string( + reinterpret_cast<const char*>(data), sizeof(data)))); + char buf[10]; + auto got = reader->read(buf, sizeof(buf)); + ASSERT_TRUE(got.has_value()); + EXPECT_EQ(0, got.value()); +} + +TEST(z_decompress, hello) { + static const unsigned char data[] = { + 0x1f, 0x8b, 0x08, 0x08, 0xf7, 0xd5, 0xbd, 0x68, + 0x02, 0x03, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00, + 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x07, 0x00, 0x82, + 0x89, 0xd1, 0xf7, 0x05, 0x00, 0x00, 0x00, + }; + auto reader = decompress::gzip(io::memory(std::string( + reinterpret_cast<const char*>(data), sizeof(data)))); + char buf[10]; + auto got = reader->read(buf, sizeof(buf)); + ASSERT_TRUE(got.has_value()); + EXPECT_EQ(5, got.value()); + buf[5] = '\0'; + EXPECT_STREQ("Hello", buf); +} + +TEST(xz_decompress, empty) { + static const unsigned char data[] = { + 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00, 0x00, 0x04, + 0xe6, 0xd6, 0xb4, 0x46, 0x00, 0x00, 0x00, 0x00, + 0x1c, 0xdf, 0x44, 0x21, 0x1f, 0xb6, 0xf3, 0x7d, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x59, 0x5a + }; + auto reader = decompress::xz(io::memory(std::string( + reinterpret_cast<const char*>(data), sizeof(data)))); + char buf[10]; + auto got = reader->read(buf, sizeof(buf)); + ASSERT_TRUE(got.has_value()); + EXPECT_EQ(0, got.value()); +} + +TEST(xz_decompress, hello) { + static const unsigned char data[] = { + 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00, 0x00, 0x04, + 0xe6, 0xd6, 0xb4, 0x46, 0x04, 0xc0, 0x09, 0x05, + 0x21, 0x01, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x76, 0xe9, 0x07, 0x70, + 0x01, 0x00, 0x04, 0x48, 0x65, 0x6c, 0x6c, 0x6f, + 0x00, 0x00, 0x00, 0x00, 0xc8, 0xac, 0x7b, 0xc8, + 0x3b, 0x5c, 0xcf, 0x51, 0x00, 0x01, 0x25, 0x05, + 0x43, 0x91, 0x1f, 0xb8, 0x1f, 0xb6, 0xf3, 0x7d, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x59, 0x5a, + }; + auto reader = decompress::xz(io::memory(std::string( + reinterpret_cast<const char*>(data), sizeof(data)))); + char buf[10]; + auto got = reader->read(buf, sizeof(buf)); + ASSERT_TRUE(got.has_value()); + EXPECT_EQ(5, got.value()); + buf[5] = '\0'; + EXPECT_STREQ("Hello", buf); +} |
