archive-zip 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/LICENSE +22 -57
- data/{NEWS → NEWS.md} +29 -16
- data/README.md +250 -0
- data/Rakefile +119 -76
- data/lib/archive/support/binary_stringio.rb +9 -2
- data/lib/archive/support/time.rb +2 -2
- data/lib/archive/zip.rb +1 -1
- data/lib/archive/zip/entry.rb +2 -2
- data/lib/archive/zip/version.rb +1 -1
- data/spec/archive/zip/archive_spec.rb +54 -0
- data/spec/archive/zip/codec/deflate/compress/checksum_spec.rb +8 -6
- data/spec/archive/zip/codec/deflate/compress/close_spec.rb +13 -12
- data/spec/archive/zip/codec/deflate/compress/crc32_spec.rb +6 -4
- data/spec/archive/zip/codec/deflate/compress/data_descriptor_spec.rb +17 -10
- data/spec/archive/zip/codec/deflate/compress/new_spec.rb +7 -5
- data/spec/archive/zip/codec/deflate/compress/open_spec.rb +9 -7
- data/spec/archive/zip/codec/deflate/compress/write_spec.rb +15 -15
- data/spec/archive/zip/codec/deflate/decompress/checksum_spec.rb +6 -4
- data/spec/archive/zip/codec/deflate/decompress/close_spec.rb +10 -9
- data/spec/archive/zip/codec/deflate/decompress/crc32_spec.rb +6 -4
- data/spec/archive/zip/codec/deflate/decompress/data_descriptor_spec.rb +17 -10
- data/spec/archive/zip/codec/deflate/decompress/new_spec.rb +5 -3
- data/spec/archive/zip/codec/deflate/decompress/open_spec.rb +7 -5
- data/spec/archive/zip/codec/null_encryption/decrypt/close_spec.rb +10 -9
- data/spec/archive/zip/codec/null_encryption/decrypt/new_spec.rb +6 -4
- data/spec/archive/zip/codec/null_encryption/decrypt/open_spec.rb +8 -6
- data/spec/archive/zip/codec/null_encryption/decrypt/read_spec.rb +8 -6
- data/spec/archive/zip/codec/null_encryption/decrypt/rewind_spec.rb +9 -7
- data/spec/archive/zip/codec/null_encryption/decrypt/seek_spec.rb +15 -13
- data/spec/archive/zip/codec/null_encryption/decrypt/tell_spec.rb +8 -6
- data/spec/archive/zip/codec/null_encryption/encrypt/close_spec.rb +10 -9
- data/spec/archive/zip/codec/null_encryption/encrypt/new_spec.rb +5 -3
- data/spec/archive/zip/codec/null_encryption/encrypt/open_spec.rb +9 -5
- data/spec/archive/zip/codec/null_encryption/encrypt/rewind_spec.rb +9 -7
- data/spec/archive/zip/codec/null_encryption/encrypt/seek_spec.rb +15 -13
- data/spec/archive/zip/codec/null_encryption/encrypt/tell_spec.rb +11 -9
- data/spec/archive/zip/codec/null_encryption/encrypt/write_spec.rb +12 -10
- data/spec/archive/zip/codec/store/compress/close_spec.rb +10 -9
- data/spec/archive/zip/codec/store/compress/data_descriptor_spec.rb +19 -10
- data/spec/archive/zip/codec/store/compress/new_spec.rb +5 -3
- data/spec/archive/zip/codec/store/compress/open_spec.rb +7 -5
- data/spec/archive/zip/codec/store/compress/rewind_spec.rb +9 -7
- data/spec/archive/zip/codec/store/compress/seek_spec.rb +15 -13
- data/spec/archive/zip/codec/store/compress/tell_spec.rb +11 -9
- data/spec/archive/zip/codec/store/compress/write_spec.rb +10 -10
- data/spec/archive/zip/codec/store/decompress/close_spec.rb +10 -9
- data/spec/archive/zip/codec/store/decompress/data_descriptor_spec.rb +17 -10
- data/spec/archive/zip/codec/store/decompress/new_spec.rb +5 -3
- data/spec/archive/zip/codec/store/decompress/open_spec.rb +7 -5
- data/spec/archive/zip/codec/store/decompress/read_spec.rb +8 -6
- data/spec/archive/zip/codec/store/decompress/rewind_spec.rb +9 -7
- data/spec/archive/zip/codec/store/decompress/seek_spec.rb +15 -13
- data/spec/archive/zip/codec/store/decompress/tell_spec.rb +8 -6
- data/spec/archive/zip/codec/traditional_encryption/decrypt/close_spec.rb +13 -24
- data/spec/archive/zip/codec/traditional_encryption/decrypt/new_spec.rb +6 -4
- data/spec/archive/zip/codec/traditional_encryption/decrypt/open_spec.rb +10 -6
- data/spec/archive/zip/codec/traditional_encryption/decrypt/read_spec.rb +12 -13
- data/spec/archive/zip/codec/traditional_encryption/decrypt/rewind_spec.rb +10 -12
- data/spec/archive/zip/codec/traditional_encryption/decrypt/seek_spec.rb +16 -18
- data/spec/archive/zip/codec/traditional_encryption/decrypt/tell_spec.rb +8 -6
- data/spec/archive/zip/codec/traditional_encryption/encrypt/close_spec.rb +13 -24
- data/spec/archive/zip/codec/traditional_encryption/encrypt/new_spec.rb +5 -3
- data/spec/archive/zip/codec/traditional_encryption/encrypt/open_spec.rb +7 -5
- data/spec/archive/zip/codec/traditional_encryption/encrypt/rewind_spec.rb +10 -12
- data/spec/archive/zip/codec/traditional_encryption/encrypt/seek_spec.rb +16 -18
- data/spec/archive/zip/codec/traditional_encryption/encrypt/tell_spec.rb +12 -14
- data/spec/archive/zip/codec/traditional_encryption/encrypt/write_spec.rb +8 -23
- data/spec/binary_stringio/new_spec.rb +18 -12
- data/spec/binary_stringio/set_encoding_spec.rb +10 -7
- data/spec/ioextensions/read_exactly_spec.rb +14 -12
- data/spec/zlib/zreader/checksum_spec.rb +10 -8
- data/spec/zlib/zreader/close_spec.rb +5 -3
- data/spec/zlib/zreader/compressed_size_spec.rb +6 -4
- data/spec/zlib/zreader/new_spec.rb +7 -5
- data/spec/zlib/zreader/open_spec.rb +9 -7
- data/spec/zlib/zreader/read_spec.rb +10 -8
- data/spec/zlib/zreader/rewind_spec.rb +7 -5
- data/spec/zlib/zreader/seek_spec.rb +13 -11
- data/spec/zlib/zreader/tell_spec.rb +8 -6
- data/spec/zlib/zreader/uncompressed_size_spec.rb +6 -4
- data/spec/zlib/zwriter/checksum_spec.rb +10 -8
- data/spec/zlib/zwriter/close_spec.rb +5 -3
- data/spec/zlib/zwriter/compressed_size_spec.rb +6 -4
- data/spec/zlib/zwriter/new_spec.rb +10 -8
- data/spec/zlib/zwriter/open_spec.rb +12 -10
- data/spec/zlib/zwriter/rewind_spec.rb +9 -7
- data/spec/zlib/zwriter/seek_spec.rb +15 -17
- data/spec/zlib/zwriter/tell_spec.rb +11 -9
- data/spec/zlib/zwriter/uncompressed_size_spec.rb +6 -4
- data/spec/zlib/zwriter/write_spec.rb +9 -9
- metadata +268 -217
- data/CONTRIBUTORS +0 -13
- data/GPL +0 -676
- data/HACKING +0 -105
- data/LEGAL +0 -8
- data/README +0 -151
- data/TODO +0 -5
- data/default.mspec +0 -8
- data/spec_helper.rb +0 -49
@@ -1,34 +1,40 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
4
5
|
require 'archive/support/binary_stringio'
|
5
6
|
|
6
7
|
describe "BinaryStringIO.new" do
|
7
8
|
it "returns a new instance" do
|
8
9
|
io = BinaryStringIO.new
|
9
|
-
io.
|
10
|
+
io.must_be_instance_of BinaryStringIO
|
10
11
|
io.close
|
11
12
|
end
|
12
13
|
|
13
14
|
it "creates a decendent of StringIO" do
|
14
15
|
io = BinaryStringIO.new
|
15
|
-
io.
|
16
|
+
io.must_be_kind_of StringIO
|
16
17
|
io.close
|
17
18
|
end
|
18
19
|
|
20
|
+
# TODO:
|
21
|
+
# This is lame. Break this out as augmentation for the "returns a new
|
22
|
+
# instance" test.
|
19
23
|
it "takes the same arguments as StringIO.new" do
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
BinaryStringIO.new.must_be_instance_of BinaryStringIO
|
25
|
+
BinaryStringIO.new('').must_be_instance_of BinaryStringIO
|
26
|
+
BinaryStringIO.new('', 'r').must_be_instance_of BinaryStringIO
|
27
|
+
BinaryStringIO.new('', 'w').must_be_instance_of BinaryStringIO
|
24
28
|
|
25
|
-
lambda { BinaryStringIO.new('', 'w', 42) }.
|
29
|
+
lambda { BinaryStringIO.new('', 'w', 42) }.must_raise ArgumentError
|
26
30
|
end
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
io.external_encoding.should == Encoding::ASCII_8BIT
|
32
|
+
it "sets the external encoding to binary" do
|
33
|
+
unless Object.const_defined?(:Encoding)
|
34
|
+
skip("Encoding methods are not supported on current Ruby (#{RUBY_DESCRIPTION})")
|
32
35
|
end
|
36
|
+
|
37
|
+
io = BinaryStringIO.new
|
38
|
+
io.external_encoding.must_equal Encoding::ASCII_8BIT
|
33
39
|
end
|
34
40
|
end
|
@@ -1,14 +1,17 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
4
5
|
require 'archive/support/binary_stringio'
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
BinaryStringIO.new.set_encoding('utf-8')
|
11
|
-
end.should raise_error(NoMethodError)
|
7
|
+
describe "BinaryStringIO#set_encoding" do
|
8
|
+
it "raises an exception when called" do
|
9
|
+
unless Object.const_defined?(:Encoding)
|
10
|
+
skip("Encoding methods are not supported on current Ruby (#{RUBY_DESCRIPTION})")
|
12
11
|
end
|
12
|
+
|
13
|
+
lambda do
|
14
|
+
BinaryStringIO.new.set_encoding('utf-8')
|
15
|
+
end.must_raise RuntimeError
|
13
16
|
end
|
14
17
|
end
|
@@ -1,50 +1,52 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
4
5
|
require 'archive/support/ioextensions.rb'
|
5
6
|
require 'archive/support/binary_stringio'
|
6
7
|
|
7
8
|
describe "IOExtensions.read_exactly" do
|
8
9
|
it "reads and returns length bytes from a given IO object" do
|
9
10
|
io = BinaryStringIO.new('This is test data')
|
10
|
-
IOExtensions.read_exactly(io, 4).
|
11
|
-
IOExtensions.read_exactly(io, 13).
|
11
|
+
IOExtensions.read_exactly(io, 4).must_equal 'This'
|
12
|
+
IOExtensions.read_exactly(io, 13).must_equal ' is test data'
|
12
13
|
end
|
13
14
|
|
14
15
|
it "raises an error when too little data is available" do
|
15
16
|
io = BinaryStringIO.new('This is test data')
|
16
17
|
lambda do
|
17
18
|
IOExtensions.read_exactly(io, 18)
|
18
|
-
end.
|
19
|
+
end.must_raise EOFError
|
19
20
|
end
|
20
21
|
|
21
22
|
it "takes an optional buffer argument and fills it" do
|
22
23
|
io = BinaryStringIO.new('This is test data')
|
23
24
|
buffer = ''
|
24
25
|
IOExtensions.read_exactly(io, 4, buffer)
|
25
|
-
buffer.
|
26
|
+
buffer.must_equal 'This'
|
26
27
|
buffer = ''
|
27
28
|
IOExtensions.read_exactly(io, 13, buffer)
|
28
|
-
buffer.
|
29
|
+
buffer.must_equal ' is test data'
|
29
30
|
end
|
30
31
|
|
31
32
|
it "empties the optional buffer before filling it" do
|
32
33
|
io = BinaryStringIO.new('This is test data')
|
33
34
|
buffer = ''
|
34
35
|
IOExtensions.read_exactly(io, 4, buffer)
|
35
|
-
buffer.
|
36
|
+
buffer.must_equal 'This'
|
36
37
|
IOExtensions.read_exactly(io, 13, buffer)
|
37
|
-
buffer.
|
38
|
+
buffer.must_equal ' is test data'
|
38
39
|
end
|
39
40
|
|
40
41
|
it "can read 0 bytes" do
|
41
42
|
io = BinaryStringIO.new('This is test data')
|
42
|
-
IOExtensions.read_exactly(io, 0).
|
43
|
+
IOExtensions.read_exactly(io, 0).must_equal ''
|
43
44
|
end
|
44
45
|
|
45
46
|
it "retries partial reads" do
|
46
|
-
io =
|
47
|
-
io.
|
48
|
-
|
47
|
+
io = MiniTest::Mock.new
|
48
|
+
io.expect(:read, 'hello', [10])
|
49
|
+
io.expect(:read, 'hello', [5])
|
50
|
+
IOExtensions.read_exactly(io, 10).must_equal 'hellohello'
|
49
51
|
end
|
50
52
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/support/zlib'
|
6
8
|
|
7
9
|
describe "Zlib::ZReader#checksum" do
|
@@ -9,32 +11,32 @@ describe "Zlib::ZReader#checksum" do
|
|
9
11
|
closed_zr = ZlibSpecs.compressed_data do |f|
|
10
12
|
Zlib::ZReader.open(f, 15) do |zr|
|
11
13
|
zr.read
|
12
|
-
zr.checksum.
|
14
|
+
zr.checksum.must_equal Zlib.adler32(ZlibSpecs.test_data)
|
13
15
|
zr
|
14
16
|
end
|
15
17
|
end
|
16
|
-
closed_zr.checksum.
|
18
|
+
closed_zr.checksum.must_equal Zlib.adler32(ZlibSpecs.test_data)
|
17
19
|
end
|
18
20
|
|
19
21
|
it "computes the CRC32 checksum of gzip formatted data" do
|
20
22
|
closed_zr = ZlibSpecs.compressed_data_gzip do |f|
|
21
23
|
Zlib::ZReader.open(f, 31) do |zr|
|
22
24
|
zr.read
|
23
|
-
zr.checksum.
|
25
|
+
zr.checksum.must_equal Zlib.crc32(ZlibSpecs.test_data)
|
24
26
|
zr
|
25
27
|
end
|
26
28
|
end
|
27
|
-
closed_zr.checksum.
|
29
|
+
closed_zr.checksum.must_equal Zlib.crc32(ZlibSpecs.test_data)
|
28
30
|
end
|
29
31
|
|
30
32
|
it "does not compute a checksum for raw zlib data" do
|
31
33
|
closed_zr = ZlibSpecs.compressed_data_raw do |f|
|
32
34
|
Zlib::ZReader.open(f, -15) do |zr|
|
33
35
|
zr.read
|
34
|
-
zr.checksum.
|
36
|
+
zr.checksum.must_equal nil
|
35
37
|
zr
|
36
38
|
end
|
37
39
|
end
|
38
|
-
closed_zr.checksum.
|
40
|
+
closed_zr.checksum.must_equal nil
|
39
41
|
end
|
40
42
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/support/zlib'
|
6
8
|
require 'archive/support/binary_stringio'
|
7
9
|
|
@@ -9,6 +11,6 @@ describe "Zlib::ZReader.close" do
|
|
9
11
|
it "closes the stream" do
|
10
12
|
zr = Zlib::ZReader.new(BinaryStringIO.new)
|
11
13
|
zr.close
|
12
|
-
zr.closed?.
|
14
|
+
zr.closed?.must_equal true
|
13
15
|
end
|
14
16
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/support/zlib'
|
6
8
|
|
7
9
|
describe "Zlib::ZReader#compressed_size" do
|
@@ -9,10 +11,10 @@ describe "Zlib::ZReader#compressed_size" do
|
|
9
11
|
closed_zr = ZlibSpecs.compressed_data_raw do |compressed_data|
|
10
12
|
Zlib::ZReader.open(compressed_data, -15) do |zr|
|
11
13
|
zr.read
|
12
|
-
zr.compressed_size.
|
14
|
+
zr.compressed_size.must_equal 160
|
13
15
|
zr
|
14
16
|
end
|
15
17
|
end
|
16
|
-
closed_zr.compressed_size.
|
18
|
+
closed_zr.compressed_size.must_equal 160
|
17
19
|
end
|
18
20
|
end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/support/zlib'
|
6
8
|
require 'archive/support/binary_stringio'
|
7
9
|
|
8
10
|
describe "Zlib::ZReader.new" do
|
9
11
|
it "returns a new instance" do
|
10
|
-
Zlib::ZReader.new(BinaryStringIO.new).class.
|
12
|
+
Zlib::ZReader.new(BinaryStringIO.new).class.must_equal Zlib::ZReader
|
11
13
|
end
|
12
14
|
|
13
15
|
it "does not require window_bits to be set" do
|
@@ -19,7 +21,7 @@ describe "Zlib::ZReader.new" do
|
|
19
21
|
compressed_data.rewind
|
20
22
|
|
21
23
|
zr = Zlib::ZReader.new(compressed_data)
|
22
|
-
zr.read.
|
24
|
+
zr.read.must_equal data
|
23
25
|
zr.close
|
24
26
|
end
|
25
27
|
|
@@ -35,7 +37,7 @@ describe "Zlib::ZReader.new" do
|
|
35
37
|
compressed_data.rewind
|
36
38
|
|
37
39
|
zr = Zlib::ZReader.new(compressed_data, window_bits)
|
38
|
-
zr.read.
|
40
|
+
zr.read.must_equal data
|
39
41
|
zr.close
|
40
42
|
end
|
41
43
|
end
|
@@ -1,21 +1,23 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/support/zlib'
|
6
8
|
require 'archive/support/binary_stringio'
|
7
9
|
|
8
10
|
describe "Zlib::ZReader.open" do
|
9
11
|
it "returns a new instance when run without a block" do
|
10
|
-
Zlib::ZReader.open(BinaryStringIO.new).class.
|
12
|
+
Zlib::ZReader.open(BinaryStringIO.new).class.must_equal Zlib::ZReader
|
11
13
|
end
|
12
14
|
|
13
15
|
it "executes a block with a new instance as an argument" do
|
14
|
-
Zlib::ZReader.open(BinaryStringIO.new) { |zr| zr.class.
|
16
|
+
Zlib::ZReader.open(BinaryStringIO.new) { |zr| zr.class.must_equal Zlib::ZReader }
|
15
17
|
end
|
16
18
|
|
17
19
|
it "closes the object after executing a block" do
|
18
|
-
Zlib::ZReader.open(BinaryStringIO.new) { |zr| zr }.closed?.
|
20
|
+
Zlib::ZReader.open(BinaryStringIO.new) { |zr| zr }.closed?.must_equal true
|
19
21
|
end
|
20
22
|
|
21
23
|
it "does not require window_bits to be set" do
|
@@ -27,7 +29,7 @@ describe "Zlib::ZReader.open" do
|
|
27
29
|
compressed_data.rewind
|
28
30
|
|
29
31
|
Zlib::ZReader.open(compressed_data) do |zr|
|
30
|
-
zr.read.
|
32
|
+
zr.read.must_equal data
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
@@ -43,7 +45,7 @@ describe "Zlib::ZReader.open" do
|
|
43
45
|
compressed_data.rewind
|
44
46
|
|
45
47
|
Zlib::ZReader.open(compressed_data, window_bits) do |zr|
|
46
|
-
zr.read.
|
48
|
+
zr.read.must_equal data
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/support/zlib'
|
6
8
|
require 'archive/support/binary_stringio'
|
7
9
|
|
8
10
|
describe "Zlib::ZReader#read" do
|
9
11
|
it "calls the read method of the delegate" do
|
10
|
-
delegate =
|
11
|
-
delegate.
|
12
|
+
delegate = MiniTest::Mock.new
|
13
|
+
delegate.expect(:read, nil, [Integer])
|
12
14
|
Zlib::ZReader.open(delegate) do |zr|
|
13
15
|
# Capture and ignore the Zlib::BufError which is generated due to mocking.
|
14
16
|
begin
|
@@ -21,27 +23,27 @@ describe "Zlib::ZReader#read" do
|
|
21
23
|
it "decompresses compressed data" do
|
22
24
|
ZlibSpecs.compressed_data do |cd|
|
23
25
|
Zlib::ZReader.open(cd) do |zr|
|
24
|
-
zr.read.
|
26
|
+
zr.read.must_equal ZlibSpecs.test_data
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
31
|
it "raises Zlib::DataError when reading invalid data" do
|
30
32
|
Zlib::ZReader.open(BinaryStringIO.new('This is not compressed data')) do |zr|
|
31
|
-
lambda { zr.read }.
|
33
|
+
lambda { zr.read }.must_raise Zlib::DataError
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
37
|
it "raises Zlib::BufError when reading truncated data" do
|
36
38
|
truncated_data = ZlibSpecs.compressed_data { |cd| cd.read(100) }
|
37
39
|
Zlib::ZReader.open(BinaryStringIO.new(truncated_data)) do |zr|
|
38
|
-
lambda { zr.read }.
|
40
|
+
lambda { zr.read }.must_raise Zlib::BufError
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
42
44
|
it "raises Zlib::BufError when reading empty data" do
|
43
45
|
Zlib::ZReader.open(BinaryStringIO.new()) do |zr|
|
44
|
-
lambda { zr.read }.
|
46
|
+
lambda { zr.read }.must_raise Zlib::BufError
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/support/zlib'
|
6
8
|
|
7
9
|
describe "Zlib::ZReader#rewind" do
|
@@ -9,15 +11,15 @@ describe "Zlib::ZReader#rewind" do
|
|
9
11
|
ZlibSpecs.compressed_data do |cd|
|
10
12
|
Zlib::ZReader.open(cd) do |zr|
|
11
13
|
zr.read(4)
|
12
|
-
|
13
|
-
zr.read.
|
14
|
+
zr.rewind
|
15
|
+
zr.read.must_equal ZlibSpecs.test_data
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
20
|
it "raises Errno::EINVAL when attempting to rewind the stream when the delegate does not respond to rewind" do
|
19
21
|
Zlib::ZReader.open(Object.new) do |zr|
|
20
|
-
lambda { zr.rewind }.
|
22
|
+
lambda { zr.rewind }.must_raise Errno::EINVAL
|
21
23
|
end
|
22
24
|
end
|
23
25
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/support/zlib'
|
6
8
|
|
7
9
|
describe "Zlib::ZReader#seek" do
|
@@ -9,14 +11,14 @@ describe "Zlib::ZReader#seek" do
|
|
9
11
|
ZlibSpecs.compressed_data do |cd|
|
10
12
|
Zlib::ZReader.open(cd) do |zr|
|
11
13
|
zr.read(4)
|
12
|
-
|
14
|
+
zr.seek(0).must_equal 0
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
17
19
|
it "raises Errno::EINVAL when attempting to seek to the beginning of the stream when the delegate does not respond to rewind" do
|
18
20
|
Zlib::ZReader.open(Object.new) do |zr|
|
19
|
-
lambda { zr.seek(0) }.
|
21
|
+
lambda { zr.seek(0) }.must_raise Errno::EINVAL
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
@@ -28,8 +30,8 @@ describe "Zlib::ZReader#seek" do
|
|
28
30
|
zr.fill_size = 0
|
29
31
|
|
30
32
|
zr.read(4)
|
31
|
-
lambda { zr.seek(1, IO::SEEK_CUR) }.
|
32
|
-
lambda { zr.seek(-1, IO::SEEK_CUR) }.
|
33
|
+
lambda { zr.seek(1, IO::SEEK_CUR) }.must_raise Errno::EINVAL
|
34
|
+
lambda { zr.seek(-1, IO::SEEK_CUR) }.must_raise Errno::EINVAL
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
@@ -37,8 +39,8 @@ describe "Zlib::ZReader#seek" do
|
|
37
39
|
it "raises Errno::EINVAL when seeking a non-zero offset relative to the beginning of the stream" do
|
38
40
|
ZlibSpecs.compressed_data do |cd|
|
39
41
|
Zlib::ZReader.open(cd) do |zr|
|
40
|
-
lambda { zr.seek(-1, IO::SEEK_SET) }.
|
41
|
-
lambda { zr.seek(1, IO::SEEK_SET) }.
|
42
|
+
lambda { zr.seek(-1, IO::SEEK_SET) }.must_raise Errno::EINVAL
|
43
|
+
lambda { zr.seek(1, IO::SEEK_SET) }.must_raise Errno::EINVAL
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end
|
@@ -46,9 +48,9 @@ describe "Zlib::ZReader#seek" do
|
|
46
48
|
it "raises Errno::EINVAL when seeking relative to the end of the stream" do
|
47
49
|
ZlibSpecs.compressed_data do |cd|
|
48
50
|
Zlib::ZReader.open(cd) do |zr|
|
49
|
-
lambda { zr.seek(0, IO::SEEK_END) }.
|
50
|
-
lambda { zr.seek(-1, IO::SEEK_END) }.
|
51
|
-
lambda { zr.seek(1, IO::SEEK_END) }.
|
51
|
+
lambda { zr.seek(0, IO::SEEK_END) }.must_raise Errno::EINVAL
|
52
|
+
lambda { zr.seek(-1, IO::SEEK_END) }.must_raise Errno::EINVAL
|
53
|
+
lambda { zr.seek(1, IO::SEEK_END) }.must_raise Errno::EINVAL
|
52
54
|
end
|
53
55
|
end
|
54
56
|
end
|