Created
April 8, 2024 19:02
-
-
Save Adenilson/9da666c138528069084dff447d5230c5 to your computer and use it in GitHub Desktop.
big_payloads.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/third_party/zlib/contrib/tests/utils_unittest.cc b/third_party/zlib/contrib/tests/utils_unittest.cc | |
index 0cc10813775f3..6f01b93a7f135 100644 | |
--- a/third_party/zlib/contrib/tests/utils_unittest.cc | |
+++ b/third_party/zlib/contrib/tests/utils_unittest.cc | |
@@ -20,7 +20,8 @@ | |
#include "zlib.h" | |
-void TestPayloads(size_t input_size, zlib_internal::WrapperType type) { | |
+void TestPayloads(size_t input_size, zlib_internal::WrapperType type, | |
+ const int compression_level = Z_DEFAULT_COMPRESSION) { | |
std::vector<unsigned char> input; | |
input.reserve(input_size); | |
for (size_t i = 1; i <= input_size; ++i) | |
@@ -36,7 +37,7 @@ void TestPayloads(size_t input_size, zlib_internal::WrapperType type) { | |
unsigned long compressed_size = static_cast<unsigned long>(compressed.size()); | |
int result = zlib_internal::CompressHelper( | |
type, compressed.data(), &compressed_size, input.data(), input.size(), | |
- Z_DEFAULT_COMPRESSION, nullptr, nullptr); | |
+ compression_level, nullptr, nullptr); | |
ASSERT_EQ(result, Z_OK); | |
unsigned long decompressed_size = | |
@@ -67,6 +68,24 @@ TEST(ZlibTest, RawWrapper) { | |
TestPayloads(i, zlib_internal::WrapperType::ZRAW); | |
} | |
+TEST(ZlibTest, LargePayloads) { | |
+ auto lengths = { 6000, 8000, 10000, 15000, 20000, 30000, 50000, 100000, | |
+ 150000, 2500000, 5000000, 10000000, 20000000 }; | |
+ | |
+ for (const auto &i: lengths) { | |
+ TestPayloads(i, zlib_internal::WrapperType::ZLIB); | |
+ TestPayloads(i, zlib_internal::WrapperType::GZIP); | |
+ } | |
+} | |
+ | |
+TEST(ZlibTest, CompressionLevels) { | |
+ auto levels = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; | |
+ for (const auto &i: levels) { | |
+ TestPayloads(10000000, zlib_internal::WrapperType::ZLIB, i); | |
+ TestPayloads(10000000, zlib_internal::WrapperType::GZIP, i); | |
+ } | |
+} | |
+ | |
TEST(ZlibTest, InflateCover) { | |
cover_support(); | |
cover_wrap(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment