2014-01-21 05:31:06 +08:00
|
|
|
require 'test_helper'
|
|
|
|
|
2014-07-15 23:23:48 +08:00
|
|
|
class PassThruCompressorTest < MiniTest::Test
|
2014-01-21 05:31:06 +08:00
|
|
|
include CrcTest
|
|
|
|
|
|
|
|
def test_size
|
|
|
|
File.open("test/dummy.txt", "wb") {
|
|
|
|
|file|
|
|
|
|
compressor = ::Zip::PassThruCompressor.new(file)
|
|
|
|
|
|
|
|
assert_equal(0, compressor.size)
|
|
|
|
|
|
|
|
t1 = "hello world"
|
|
|
|
t2 = ""
|
|
|
|
t3 = "bingo"
|
|
|
|
|
|
|
|
compressor << t1
|
|
|
|
assert_equal(compressor.size, t1.size)
|
|
|
|
|
|
|
|
compressor << t2
|
|
|
|
assert_equal(compressor.size, t1.size + t2.size)
|
|
|
|
|
|
|
|
compressor << t3
|
|
|
|
assert_equal(compressor.size, t1.size + t2.size + t3.size)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_crc
|
|
|
|
run_crc_test(::Zip::PassThruCompressor)
|
|
|
|
end
|
|
|
|
end
|