1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
# tc_Flate.rb
require 'test/unit'
require 'Flate'
class TestFlate < Test::Unit::TestCase
def make_data(size = 10000)
srand # intitialize the random seed...
data = ""
# For some reason, there is a failure here in Ruby1.9.1, around the 768th
# iteration.
size.times do
data << [rand(256)].pack("C")
end
return data
end
def test_compression_decompression
data = make_data
data_compressed = Flate.compress(data)
data_second = Flate.expand(data_compressed)
assert_equal(data_second, data)
end
end
|