@@ -162,8 +162,23 @@ def test_decompress_igzip(data_size, level):
162
162
163
163
164
164
@pytest .mark .parametrize (["unused_size" , "wbits" ],
165
- itertools .product (range (1 ,27 ), [- 15 , 15 , 31 ]))
166
- def test_unused_data (unused_size , wbits ):
165
+ itertools .product ([26 ], [31 ]))
166
+ def test_unused_data_gzip (unused_size , wbits ):
167
+ unused_data = b"abcdefghijklmnopqrstuvwxyz" [:unused_size ]
168
+ compressor = zlib .compressobj (wbits = wbits )
169
+ data = b"A meaningful sentence stardts with a capital and ends with a."
170
+ compressed = compressor .compress (data ) + compressor .flush ()
171
+ decompressor = isal_zlib .decompressobj (wbits = wbits )
172
+ result = decompressor .decompress (compressed + unused_data )
173
+ assert result == data
174
+ assert decompressor .unused_data == unused_data
175
+
176
+
177
+ @pytest .mark .xfail (reason = "Unused data and unconsumed tail do not work "
178
+ "properly for non-gzip compression." )
179
+ @pytest .mark .parametrize (["unused_size" , "wbits" ],
180
+ itertools .product ([26 ], [- 15 , 15 ]))
181
+ def test_unused_data_zlib_raw (unused_size , wbits ):
167
182
unused_data = b"abcdefghijklmnopqrstuvwxyz" [:unused_size ]
168
183
compressor = zlib .compressobj (wbits = wbits )
169
184
data = b"A meaningful sentence stardts with a capital and ends with a."
0 commit comments