aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorK900 <me@0upti.me>2024-06-20 08:54:43 +0300
committerK900 <me@0upti.me>2024-06-20 09:21:13 +0300
commit7d52d74bbe39376f331887759020cff097dace55 (patch)
tree1403dd70b62c2922fe0859728949529c19e2aa7e /tests
parentfb7d3154115cb5cf211c5ddbc124e17ee519bb64 (diff)
BrotliDecompressionSource: don't bail out too early
If we've consumed the entire input, that doesn't actually mean we're done decompressing - there might be more output left. This worked (?) in most cases because the input and output sizes are pretty comparable, but sometimes they're not and then things get very funny. Change-Id: I73435a654a911b8ce25119f713b80706c5783c1b
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/libutil/compression.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/unit/libutil/compression.cc b/tests/unit/libutil/compression.cc
index 0542e7d33..3b40db0cd 100644
--- a/tests/unit/libutil/compression.cc
+++ b/tests/unit/libutil/compression.cc
@@ -66,6 +66,16 @@ namespace nix {
ASSERT_THROW(decompress(method, str), CompressionError);
}
+ TEST(decompress, veryLongBrotli) {
+ auto method = "br";
+ auto str = std::string(65536, 'a');
+ auto o = decompress(method, compress(method, str));
+
+ // This is just to not print 64k of "a" for most failures
+ ASSERT_EQ(o.length(), str.length());
+ ASSERT_EQ(o, str);
+ }
+
/* ----------------------------------------------------------------------------
* compression sinks
* --------------------------------------------------------------------------*/