Module: DecompressorTests

Included in:
InflaterTest, PassThruDecompressorTest
Defined in:
lib/hotplate/gems/rubyzip-1.1.7/test/test_helper.rb

Constant Summary collapse

TEST_FILE =

expects @refText, @refLines and @decompressor

"test/data/file1.txt"

Instance Method Summary collapse

Instance Method Details

#setupObject



56
57
58
59
60
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/test_helper.rb', line 56

def setup
  @refText = ''
  File.open(TEST_FILE) { |f| @refText = f.read }
  @refLines = @refText.split($/)
end

#test_mixingReadsAndProduceInputObject



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/test_helper.rb', line 74

def test_mixingReadsAndProduceInput
  # Just some preconditions to make sure we have enough data for this test
  assert(@refText.length > 1000)
  assert(@refLines.length > 40)


  assert_equal(@refText[0...100], @decompressor.sysread(100))

  assert(!@decompressor.input_finished?)
  buf = @decompressor.produce_input
  assert_equal(@refText[100...(100+buf.length)], buf)
end

#test_readEverythingObject



62
63
64
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/test_helper.rb', line 62

def test_readEverything
  assert_equal(@refText, @decompressor.sysread)
end

#test_readInChunksObject



66
67
68
69
70
71
72
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/test_helper.rb', line 66

def test_readInChunks
  chunkSize = 5
  while (decompressedChunk = @decompressor.sysread(chunkSize))
    assert_equal(@refText.slice!(0, chunkSize), decompressedChunk)
  end
  assert_equal(0, @refText.size)
end