From fd57b0a73de5e9abd0348cf391303f7aa80b6b3c Mon Sep 17 00:00:00 2001 From: Damian Jarek Date: Mon, 16 Sep 2019 14:27:30 +0200 Subject: [PATCH] Test for match length exceeding lookahead in deflate stream Signed-off-by: Damian Jarek --- test/beast/zlib/deflate_stream.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/beast/zlib/deflate_stream.cpp b/test/beast/zlib/deflate_stream.cpp index 2c6cbeeb..1a209778 100644 --- a/test/beast/zlib/deflate_stream.cpp +++ b/test/beast/zlib/deflate_stream.cpp @@ -441,6 +441,29 @@ public: } } + void + testRLEMatchLengthExceedLookahead() + { + z_params zp; + deflate_stream ds; + std::vector in; + in.resize(300); + + + ds.reset(8, 15, 1, Strategy::rle); + std::fill_n(in.begin(), 4, 'a'); + std::string out; + out.resize(in.size() * 2); + zp.next_in = in.data(); + zp.avail_in = in.size(); + zp.next_out = &out.front(); + zp.avail_out = out.size(); + + error_code ec; + ds.write(zp, Flush::sync, ec); + BEAST_EXPECT(!ec); + } + void run() override { @@ -453,6 +476,7 @@ public: testWriteAfterFinish(); testFlushPartial(); testFlushAtLiteralBufferFull(); + testRLEMatchLengthExceedLookahead(); } };