File: tc_Flate.rb

package info (click to toggle)
libtioga-ruby 1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 9,956 kB
  • ctags: 3,257
  • sloc: ansic: 31,801; ruby: 16,346; sh: 172; makefile: 114
file content (46 lines) | stat: -rw-r--r-- 560 bytes parent folder | download | duplicates (2)
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
46
#  tc_Flate.rb

require 'test/unit'
require 'Flate'

class TestFlate < Test::Unit::TestCase

  def make_data(size = 10000) 
    srand # intitialize the random seed...
    data = ""
    i = 0
    while i < size
      # not efficicent, but this will have to do ;-) !
      data += [rand(256)].pack("C")
      i += 1
    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