File: tc_Flate.rb

package info (click to toggle)
ruby-tioga 1.14-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 10,508 kB
  • sloc: ansic: 39,112; ruby: 17,031; sh: 79; makefile: 29
file content (45 lines) | stat: -rw-r--r-- 576 bytes parent folder | download | duplicates (6)
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