From 4585327da813fb37eaaf75c4126e99cb6a86ada5 Mon Sep 17 00:00:00 2001 From: SpringMT Date: Fri, 24 May 2024 16:27:21 +0900 Subject: [PATCH] tests: add decompress with large streaming compress data --- spec/zstd-ruby_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/zstd-ruby_spec.rb b/spec/zstd-ruby_spec.rb index ba39ea8..0810423 100644 --- a/spec/zstd-ruby_spec.rb +++ b/spec/zstd-ruby_spec.rb @@ -95,6 +95,17 @@ def to_str expect(Zstd.decompress(simple_compressed).force_encoding('UTF-8').hash).to eq(Zstd.decompress(streaming_compressed).force_encoding('UTF-8').hash) end + it 'shoud work with large streaming compress data' do + large_strings = Random.bytes(1<<16) + stream = Zstd::StreamingCompress.new + res = stream.compress(large_strings) + res << stream.flush + res << stream.compress(large_strings) + res << stream.compress(large_strings) + res << stream.finish + expect(Zstd.decompress(res)).to eq(large_strings * 3) + end + it 'should raise exception with unsupported object' do expect { Zstd.decompress(Object.new) }.to raise_error(TypeError) end