161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
# File 'lib/adsp/test/stream/reader.rb', line 161
def test_read_with_large_texts
options_generator = OCG.new(
:text => LARGE_TEXTS,
:with_buffer => Option::BOOLS
)
Common.parallel_options options_generator do |options|
text = options[:text]
with_buffer = options[:with_buffer]
archive = get_archive text
prev_result = "".b
LARGE_PORTION_LENGTHS.each do |portion_length|
instance = target.new ::StringIO.new(archive)
decompressed_text = "".b
begin
loop do
result =
if with_buffer
instance.read portion_length, prev_result
else
instance.read portion_length
end
break if result.nil?
assert_equal prev_result, result if with_buffer
decompressed_text << result
end
ensure
instance.close
end
decompressed_text.force_encoding text.encoding
assert_equal text, decompressed_text
end
instance = target.new ::StringIO.new(archive)
decompressed_text = nil
begin
if with_buffer
decompressed_text = instance.read nil, prev_result
assert_equal prev_result, decompressed_text
else
decompressed_text = instance.read
end
ensure
instance.close
end
decompressed_text.force_encoding text.encoding
assert_equal text, decompressed_text
end
end
|