pr-zlib 1.0.5 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/{CHANGES → CHANGES.md} +19 -6
  4. data/Gemfile +6 -0
  5. data/MANIFEST.md +20 -0
  6. data/{README → README.md} +29 -12
  7. data/Rakefile +11 -61
  8. data/bin/{minizip.rb → minirbgzip} +77 -65
  9. data/lib/pr/rbzlib/bytef.rb +16 -0
  10. data/lib/pr/rbzlib/bytef_arr.rb +29 -0
  11. data/lib/pr/rbzlib/bytef_str.rb +52 -0
  12. data/lib/pr/rbzlib/posf.rb +33 -0
  13. data/lib/pr/rbzlib.rb +1758 -1855
  14. data/lib/pr/zlib/deflate.rb +99 -0
  15. data/lib/pr/zlib/errors.rb +27 -0
  16. data/lib/pr/zlib/gzipfile.rb +315 -0
  17. data/lib/pr/zlib/gzipfile_errors.rb +19 -0
  18. data/lib/pr/zlib/gzipreader.rb +338 -0
  19. data/lib/pr/zlib/gzipwriter.rb +167 -0
  20. data/lib/pr/zlib/inflate.rb +114 -0
  21. data/lib/pr/zlib/zstream.rb +417 -0
  22. data/lib/pr/zlib.rb +25 -1466
  23. data/pr-zlib.gemspec +15 -15
  24. data/profile/bench_pr_zlib.rb +7 -5
  25. data/profile/bench_zlib.rb +7 -5
  26. data/profile/profile_pr_zlib_read.rb +3 -3
  27. data/profile/profile_pr_zlib_write.rb +3 -3
  28. data/spec/README.md +46 -0
  29. data/spec/rbzlib/bytef_arr_spec.rb +82 -0
  30. data/spec/rbzlib/bytef_spec.rb +72 -0
  31. data/spec/rbzlib/bytef_str_spec.rb +113 -0
  32. data/spec/rbzlib/posf_spec.rb +83 -0
  33. data/spec/rbzlib_spec.rb +170 -0
  34. data/spec/spec_helper.rb +27 -0
  35. data/spec/zlib/deflate_spec.rb +44 -0
  36. data/spec/zlib/gzip_file_spec.rb +86 -0
  37. data/spec/zlib/gzip_reader_spec.rb +276 -0
  38. data/spec/zlib/gzip_writer_spec.rb +275 -0
  39. data/spec/zlib/inflate_spec.rb +44 -0
  40. data/spec/zlib/zstream_spec.rb +156 -0
  41. data/spec/zlib_spec.rb +195 -0
  42. data.tar.gz.sig +0 -0
  43. metadata +68 -55
  44. metadata.gz.sig +0 -0
  45. data/MANIFEST +0 -20
  46. data/test/test_rbzlib.rb +0 -133
  47. data/test/test_rbzlib_bytef.rb +0 -76
  48. data/test/test_rbzlib_posf.rb +0 -56
  49. data/test/test_zlib.rb +0 -162
  50. data/test/test_zlib_deflate.rb +0 -55
  51. data/test/test_zlib_gzip_file.rb +0 -93
  52. data/test/test_zlib_gzip_reader.rb +0 -183
  53. data/test/test_zlib_gzip_writer.rb +0 -186
  54. data/test/test_zlib_inflate.rb +0 -55
  55. data/test/test_zlib_zstream.rb +0 -146
@@ -0,0 +1,275 @@
1
+ # frozen_string_literal: true
2
+
3
+ ########################################################################
4
+ # gzip_writer_spec.rb
5
+ #
6
+ # Spec for the Zlib::GzipWriter class.
7
+ ########################################################################
8
+ require 'spec_helper'
9
+
10
+ RSpec.describe Zlib::GzipWriter do
11
+ before(:all) do
12
+ @gz_file = 'gzip_writer_test.gz'
13
+ end
14
+
15
+ after(:all) do
16
+ File.delete(@gz_file) if File.exist?(@gz_file)
17
+ end
18
+
19
+ let(:handle) { File.new(@gz_file, 'w') }
20
+ let(:writer) { described_class.new(handle) }
21
+ let(:time) { Time.now }
22
+
23
+ after do
24
+ handle.close if handle && !handle.closed?
25
+ end
26
+
27
+ describe 'constructor' do
28
+ it 'can be created with just a handle' do
29
+ expect { described_class.new(handle) }.not_to raise_error
30
+ end
31
+
32
+ it 'can be created with handle and level' do
33
+ expect { described_class.new(handle, nil) }.not_to raise_error
34
+ end
35
+
36
+ it 'can be created with handle, level, and strategy' do
37
+ expect { described_class.new(handle, nil, nil) }.not_to raise_error
38
+ end
39
+
40
+ it 'raises ArgumentError with no arguments' do
41
+ expect { described_class.new }.to raise_error(ArgumentError)
42
+ end
43
+ end
44
+
45
+ describe '#level' do
46
+ it 'responds to level' do
47
+ expect(writer).to respond_to(:level)
48
+ end
49
+
50
+ it 'returns the default compression level' do
51
+ expect(writer.level).to eq(Rbzlib::Z_DEFAULT_COMPRESSION)
52
+ end
53
+ end
54
+
55
+ describe '#mtime' do
56
+ it 'responds to mtime getter' do
57
+ expect(writer).to respond_to(:mtime)
58
+ end
59
+
60
+ it 'can get mtime without errors' do
61
+ expect { writer.mtime }.not_to raise_error
62
+ end
63
+
64
+ it 'returns a Time object' do
65
+ expect(writer.mtime).to be_a(Time)
66
+ end
67
+
68
+ it 'starts at Time.at(0)' do
69
+ expect(writer.mtime).to eq(Time.at(0))
70
+ end
71
+
72
+ it 'responds to mtime setter' do
73
+ expect(writer).to respond_to(:mtime=)
74
+ end
75
+
76
+ it 'can set mtime without errors' do
77
+ expect { writer.mtime = time }.not_to raise_error
78
+ end
79
+
80
+ it 'returns the set value' do
81
+ expect(writer.mtime = time).to eq(time)
82
+ end
83
+ end
84
+
85
+ describe '#orig_name' do
86
+ it 'responds to orig_name getter' do
87
+ expect(writer).to respond_to(:orig_name)
88
+ end
89
+
90
+ it 'can get orig_name without errors' do
91
+ expect { writer.orig_name }.not_to raise_error
92
+ end
93
+
94
+ it 'returns nil initially' do
95
+ expect(writer.orig_name).to be_nil
96
+ end
97
+
98
+ it 'responds to orig_name setter' do
99
+ expect(writer).to respond_to(:orig_name=)
100
+ end
101
+
102
+ it 'can set orig_name without errors' do
103
+ expect { writer.orig_name = 'test' }.not_to raise_error
104
+ end
105
+
106
+ it 'returns and stores the set value' do
107
+ expect(writer.orig_name = 'test').to eq('test')
108
+ expect(writer.orig_name).to eq('test')
109
+ end
110
+ end
111
+
112
+ describe '#comment' do
113
+ it 'responds to comment getter' do
114
+ expect(writer).to respond_to(:comment)
115
+ end
116
+
117
+ it 'can get comment without errors' do
118
+ expect { writer.comment }.not_to raise_error
119
+ end
120
+
121
+ it 'returns nil initially' do
122
+ expect(writer.comment).to be_nil
123
+ end
124
+
125
+ it 'responds to comment setter' do
126
+ expect(writer).to respond_to(:comment=)
127
+ end
128
+
129
+ it 'can set comment without errors' do
130
+ expect { writer.comment = 'test' }.not_to raise_error
131
+ end
132
+
133
+ it 'returns and stores the set value' do
134
+ expect(writer.comment = 'test').to eq('test')
135
+ expect(writer.comment).to eq('test')
136
+ end
137
+ end
138
+
139
+ describe '#pos' do
140
+ it 'responds to pos' do
141
+ expect(writer).to respond_to(:pos)
142
+ end
143
+
144
+ it 'can get pos without errors' do
145
+ expect { writer.pos }.not_to raise_error
146
+ end
147
+
148
+ it 'returns an integer' do
149
+ expect(writer.pos).to be_a(Integer)
150
+ end
151
+
152
+ it 'starts at 0' do
153
+ expect(writer.pos).to eq(0)
154
+ end
155
+
156
+ it 'updates after writing' do
157
+ expect { writer.write('test') }.not_to raise_error
158
+ expect(writer.pos).to eq(4)
159
+ end
160
+
161
+ it 'has tell as an alias' do
162
+ expect(writer.method(:pos)).to eq(writer.method(:tell))
163
+ end
164
+ end
165
+
166
+ describe '.open' do
167
+ it 'responds to open class method' do
168
+ expect(described_class).to respond_to(:open)
169
+ end
170
+
171
+ it 'can open with block without errors' do
172
+ expect { described_class.open(@gz_file) {} }.not_to raise_error
173
+ end
174
+ end
175
+
176
+ describe '#flush' do
177
+ it 'responds to flush' do
178
+ expect(writer).to respond_to(:flush)
179
+ end
180
+
181
+ it 'can flush without errors' do
182
+ expect { writer.flush }.not_to raise_error
183
+ end
184
+
185
+ it 'returns self' do
186
+ expect(writer.flush).to eq(writer)
187
+ end
188
+ end
189
+
190
+ describe '#write' do
191
+ it 'responds to write' do
192
+ expect(writer).to respond_to(:write)
193
+ end
194
+
195
+ it 'can write without errors' do
196
+ expect { writer.write('test') }.not_to raise_error
197
+ end
198
+
199
+ it 'returns number of bytes written for string' do
200
+ expect(writer.write('test')).to eq(4)
201
+ end
202
+
203
+ it 'returns number of bytes written for number' do
204
+ expect(writer.write(999)).to eq(3)
205
+ end
206
+
207
+ it 'raises ArgumentError with no arguments' do
208
+ expect { writer.write }.to raise_error(ArgumentError)
209
+ end
210
+ end
211
+
212
+ describe '#putc' do
213
+ it 'responds to putc' do
214
+ expect(writer).to respond_to(:putc)
215
+ end
216
+
217
+ it 'can putc without errors' do
218
+ expect { writer.putc(97) }.not_to raise_error
219
+ end
220
+
221
+ it 'returns the character code' do
222
+ expect(writer.putc(97)).to eq(97)
223
+ end
224
+
225
+ it 'raises ArgumentError with no arguments' do
226
+ expect { writer.putc }.to raise_error(ArgumentError)
227
+ end
228
+ end
229
+
230
+ describe '#<<' do
231
+ it 'responds to <<' do
232
+ expect(writer).to respond_to(:<<)
233
+ end
234
+
235
+ it 'can append without errors' do
236
+ expect { writer << 'test' }.not_to raise_error
237
+ end
238
+
239
+ it 'raises ArgumentError with no arguments' do
240
+ expect { writer.send(:<<) }.to raise_error(ArgumentError)
241
+ end
242
+ end
243
+
244
+ describe '#printf' do
245
+ it 'responds to printf' do
246
+ expect(writer).to respond_to(:printf)
247
+ end
248
+
249
+ it 'can printf without errors' do
250
+ expect { writer.printf('%s', 'test') }.not_to raise_error
251
+ end
252
+
253
+ it 'raises ArgumentError with no arguments' do
254
+ expect { writer.printf }.to raise_error(ArgumentError)
255
+ end
256
+ end
257
+
258
+ describe '#puts' do
259
+ it 'responds to puts' do
260
+ expect(writer).to respond_to(:puts)
261
+ end
262
+
263
+ it 'can puts without errors' do
264
+ expect { writer.puts('test') }.not_to raise_error
265
+ end
266
+
267
+ it 'raises ArgumentError with no arguments' do
268
+ expect { writer.puts }.to raise_error(ArgumentError)
269
+ end
270
+
271
+ it 'raises ArgumentError with multiple arguments' do
272
+ expect { writer.puts('test1', 'test2') }.to raise_error(ArgumentError)
273
+ end
274
+ end
275
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ ########################################################################
4
+ # inflate_spec.rb
5
+ #
6
+ # Spec for the Zlib::Inflate class.
7
+ ########################################################################
8
+ require 'spec_helper'
9
+
10
+ RSpec.describe Zlib::Inflate do
11
+ let(:inflate) { described_class.new }
12
+
13
+ describe 'class methods' do
14
+ it 'responds to inflate_run' do
15
+ expect(described_class).to respond_to(:inflate_run)
16
+ end
17
+
18
+ it 'responds to inflate' do
19
+ expect(described_class).to respond_to(:inflate)
20
+ end
21
+ end
22
+
23
+ describe 'instance methods' do
24
+ it 'responds to inflate' do
25
+ expect(inflate).to respond_to(:inflate)
26
+ end
27
+
28
+ it 'responds to <<' do
29
+ expect(inflate).to respond_to(:<<)
30
+ end
31
+
32
+ it 'responds to sync' do
33
+ expect(inflate).to respond_to(:sync)
34
+ end
35
+
36
+ it 'responds to sync_point?' do
37
+ expect(inflate).to respond_to(:sync_point?)
38
+ end
39
+
40
+ it 'responds to set_dictionary' do
41
+ expect(inflate).to respond_to(:set_dictionary)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,156 @@
1
+ # frozen_string_literal: true
2
+
3
+ ########################################################################
4
+ # zstream_spec.rb
5
+ #
6
+ # Spec for the Zlib::ZStream class.
7
+ ########################################################################
8
+ require 'spec_helper'
9
+
10
+ RSpec.describe Zlib::ZStream do
11
+ let(:zstream) { described_class.new }
12
+ let(:zfunc) { Zlib::ZStreamFuncs.new }
13
+ let(:src) { Array.new(128, 0.chr) }
14
+
15
+ before do
16
+ zstream.zstream_init(zfunc)
17
+ end
18
+
19
+ describe 'accessors' do
20
+ it 'has flags accessor' do
21
+ expect(zstream).to respond_to(:flags)
22
+ expect(zstream).to respond_to(:flags=)
23
+ end
24
+
25
+ it 'has buf accessor' do
26
+ expect(zstream).to respond_to(:buf)
27
+ expect(zstream).to respond_to(:buf=)
28
+ end
29
+
30
+ it 'has input accessor' do
31
+ expect(zstream).to respond_to(:input)
32
+ expect(zstream).to respond_to(:input=)
33
+ end
34
+
35
+ it 'has stream accessor' do
36
+ expect(zstream).to respond_to(:stream)
37
+ expect(zstream).to respond_to(:stream=)
38
+ end
39
+
40
+ it 'has func accessor' do
41
+ expect(zstream).to respond_to(:func)
42
+ expect(zstream).to respond_to(:func=)
43
+ end
44
+ end
45
+
46
+ describe '#raise_zlib_error' do
47
+ it 'responds to raise_zlib_error' do
48
+ expect(zstream).to respond_to(:raise_zlib_error)
49
+ end
50
+
51
+ it 'raises StreamEnd for Z_STREAM_END' do
52
+ expect { zstream.raise_zlib_error(Rbzlib::Z_STREAM_END, nil) }.to raise_error(Zlib::StreamEnd, 'stream end')
53
+ end
54
+
55
+ it 'raises NeedDict for Z_NEED_DICT' do
56
+ expect { zstream.raise_zlib_error(Rbzlib::Z_NEED_DICT, nil) }.to raise_error(Zlib::NeedDict, 'need dictionary')
57
+ end
58
+
59
+ it 'raises StreamError for Z_STREAM_ERROR' do
60
+ expect { zstream.raise_zlib_error(Rbzlib::Z_STREAM_ERROR, nil) }.to raise_error(Zlib::StreamError, 'stream error')
61
+ end
62
+
63
+ it 'raises DataError for Z_DATA_ERROR' do
64
+ expect { zstream.raise_zlib_error(Rbzlib::Z_DATA_ERROR, nil) }.to raise_error(Zlib::DataError, 'data error')
65
+ end
66
+
67
+ it 'raises BufError for Z_BUF_ERROR' do
68
+ expect { zstream.raise_zlib_error(Rbzlib::Z_BUF_ERROR, nil) }.to raise_error(Zlib::BufError, 'buffer error')
69
+ end
70
+
71
+ it 'raises VersionError for Z_VERSION_ERROR' do
72
+ expect { zstream.raise_zlib_error(Rbzlib::Z_VERSION_ERROR, nil) }.to raise_error(Zlib::VersionError, 'incompatible version')
73
+ end
74
+
75
+ it 'raises MemError for Z_MEM_ERROR' do
76
+ expect { zstream.raise_zlib_error(Rbzlib::Z_MEM_ERROR, nil) }.to raise_error(Zlib::MemError, 'insufficient memory')
77
+ end
78
+
79
+ it 'raises SystemCallError for Z_ERRNO' do
80
+ expect { zstream.raise_zlib_error(Rbzlib::Z_ERRNO, nil) }.to raise_error(SystemCallError)
81
+ end
82
+
83
+ it 'raises Error for unknown error codes' do
84
+ expect { zstream.raise_zlib_error(999, nil) }.to raise_error(Zlib::Error)
85
+ end
86
+ end
87
+
88
+ describe '#zstream_expand_buffer' do
89
+ it 'responds to zstream_expand_buffer' do
90
+ expect(zstream).to respond_to(:zstream_expand_buffer)
91
+ end
92
+
93
+ it 'expands buffer without errors' do
94
+ expect { zstream.zstream_expand_buffer }.not_to raise_error
95
+ end
96
+
97
+ it 'sets buf after call' do
98
+ expect(zstream.buf).to be_nil
99
+ zstream.zstream_expand_buffer
100
+ expect(zstream.buf).to be_a(Bytef_str)
101
+ end
102
+
103
+ it 'raises ArgumentError with wrong number of arguments' do
104
+ expect { zstream.zstream_expand_buffer(1) }.to raise_error(ArgumentError)
105
+ end
106
+ end
107
+
108
+ describe '#zstream_append_buffer' do
109
+ it 'responds to zstream_append_buffer' do
110
+ expect(zstream).to respond_to(:zstream_append_buffer)
111
+ end
112
+
113
+ it 'appends buffer without errors' do
114
+ expect { zstream.zstream_append_buffer(src, src.length) }.not_to raise_error
115
+ end
116
+
117
+ it 'sets buf after call' do
118
+ expect(zstream.buf).to be_nil
119
+ zstream.zstream_append_buffer(src, src.length)
120
+ expect(zstream.buf).to be_a(Bytef_arr)
121
+ end
122
+
123
+ it 'raises ArgumentError without arguments' do
124
+ expect { zstream.zstream_append_buffer }.to raise_error(ArgumentError)
125
+ end
126
+ end
127
+
128
+ describe '#zstream_detach_buffer' do
129
+ it 'responds to zstream_detach_buffer' do
130
+ expect(zstream).to respond_to(:zstream_detach_buffer)
131
+ end
132
+
133
+ it 'detaches buffer without errors' do
134
+ expect { zstream.zstream_detach_buffer }.not_to raise_error
135
+ end
136
+
137
+ it 'returns a string' do
138
+ expect(zstream.zstream_detach_buffer).to be_a(String)
139
+ expect(zstream.buf).not_to be_nil
140
+ end
141
+ end
142
+
143
+ describe '#zstream_shift_buffer' do
144
+ before do
145
+ zstream.buf = Bytef.new(0.chr * Zlib::ZSTREAM_INITIAL_BUFSIZE)
146
+ end
147
+
148
+ it 'responds to zstream_shift_buffer' do
149
+ expect(zstream).to respond_to(:zstream_shift_buffer)
150
+ end
151
+
152
+ it 'shifts buffer without errors' do
153
+ expect { zstream.zstream_shift_buffer(1) }.not_to raise_error
154
+ end
155
+ end
156
+ end
data/spec/zlib_spec.rb ADDED
@@ -0,0 +1,195 @@
1
+ # frozen_string_literal: true
2
+
3
+ ########################################################################
4
+ # zlib_spec.rb
5
+ #
6
+ # Spec for the Zlib module.
7
+ ########################################################################
8
+ require 'spec_helper'
9
+
10
+ RSpec.describe Zlib do
11
+ let(:zstream_funcs) { described_class::ZStreamFuncs.new }
12
+
13
+ describe 'version constants' do
14
+ it 'has the correct Ruby zlib version' do
15
+ expect(described_class::VERSION).to eq('0.6.0')
16
+ expect(described_class::RUBY_ZLIB_VERSION).to eq('0.6.0')
17
+ end
18
+
19
+ it 'has the correct zlib version' do
20
+ expect(described_class::ZLIB_VERSION).to eq('1.2.3')
21
+ expect(described_class::PR_ZLIB_VERSION).to eq('1.1.0')
22
+ end
23
+ end
24
+
25
+ describe 'data type constants' do
26
+ it 'includes data type constants' do
27
+ expect(described_class::BINARY).not_to be_nil
28
+ expect(described_class::ASCII).not_to be_nil
29
+ expect(described_class::UNKNOWN).not_to be_nil
30
+ end
31
+ end
32
+
33
+ describe 'compression constants' do
34
+ it 'includes compression level constants' do
35
+ expect(described_class::NO_COMPRESSION).not_to be_nil
36
+ expect(described_class::BEST_SPEED).not_to be_nil
37
+ expect(described_class::BEST_COMPRESSION).not_to be_nil
38
+ expect(described_class::DEFAULT_COMPRESSION).not_to be_nil
39
+ end
40
+ end
41
+
42
+ describe 'encoding constants' do
43
+ it 'includes encoding strategy constants' do
44
+ expect(described_class::FILTERED).not_to be_nil
45
+ expect(described_class::HUFFMAN_ONLY).not_to be_nil
46
+ expect(described_class::DEFAULT_STRATEGY).not_to be_nil
47
+ expect(described_class::MAX_WBITS).not_to be_nil
48
+ expect(described_class::DEF_MEM_LEVEL).not_to be_nil
49
+ expect(described_class::MAX_MEM_LEVEL).not_to be_nil
50
+ expect(described_class::NO_FLUSH).not_to be_nil
51
+ expect(described_class::SYNC_FLUSH).not_to be_nil
52
+ expect(described_class::FULL_FLUSH).not_to be_nil
53
+ expect(described_class::FINISH).not_to be_nil
54
+ end
55
+ end
56
+
57
+ describe 'OS constants' do
58
+ it 'has the correct OS constant values' do
59
+ expect(described_class::OS_MSDOS).to eq(0x00)
60
+ expect(described_class::OS_AMIGA).to eq(0x01)
61
+ expect(described_class::OS_VMS).to eq(0x02)
62
+ expect(described_class::OS_UNIX).to eq(0x03)
63
+ expect(described_class::OS_ATARI).to eq(0x05)
64
+ expect(described_class::OS_OS2).to eq(0x06)
65
+ expect(described_class::OS_MACOS).to eq(0x07)
66
+ expect(described_class::OS_TOPS20).to eq(0x0a)
67
+ expect(described_class::OS_WIN32).to eq(0x0b)
68
+ end
69
+ end
70
+
71
+ describe 'zstream flag constants' do
72
+ it 'has the correct flag values' do
73
+ expect(described_class::ZSTREAM_FLAG_READY).to eq(0x1)
74
+ expect(described_class::ZSTREAM_FLAG_IN_STREAM).to eq(0x2)
75
+ expect(described_class::ZSTREAM_FLAG_FINISHED).to eq(0x4)
76
+ expect(described_class::ZSTREAM_FLAG_CLOSING).to eq(0x8)
77
+ expect(described_class::ZSTREAM_FLAG_UNUSED).to eq(0x10)
78
+ end
79
+ end
80
+
81
+ describe 'zstream buffer constants' do
82
+ it 'has the correct buffer size values' do
83
+ expect(described_class::ZSTREAM_INITIAL_BUFSIZE).to eq(1024)
84
+ expect(described_class::ZSTREAM_AVAIL_OUT_STEP_MAX).to eq(16384)
85
+ expect(described_class::ZSTREAM_AVAIL_OUT_STEP_MIN).to eq(2048)
86
+ end
87
+ end
88
+
89
+ describe '.zlib_version' do
90
+ it 'responds to zlib_version' do
91
+ expect(described_class).to respond_to(:zlib_version)
92
+ end
93
+ end
94
+
95
+ describe '.adler32' do
96
+ it 'responds to adler32' do
97
+ expect(described_class).to respond_to(:adler32)
98
+ end
99
+
100
+ it 'can be called without arguments' do
101
+ expect { described_class.adler32 }.not_to raise_error
102
+ end
103
+
104
+ it 'returns correct values' do
105
+ expect(described_class.adler32).to eq(1)
106
+ expect(described_class.adler32('test')).to eq(73204161)
107
+ expect(described_class.adler32(nil, 3)).to eq(1)
108
+ expect(described_class.adler32('test', 3)).to eq(73728451)
109
+ end
110
+
111
+ it 'raises RangeError for values too large' do
112
+ expect { described_class.adler32('test', 2**128) }.to raise_error(RangeError)
113
+ end
114
+ end
115
+
116
+ describe '.crc32' do
117
+ it 'responds to crc32' do
118
+ expect(described_class).to respond_to(:crc32)
119
+ end
120
+
121
+ it 'can be called without arguments' do
122
+ expect { described_class.crc32 }.not_to raise_error
123
+ end
124
+
125
+ it 'returns correct values' do
126
+ expect(described_class.crc32).to eq(0)
127
+ expect(described_class.crc32('test')).to eq(3632233996)
128
+ expect(described_class.crc32(nil, 3)).to eq(0)
129
+ expect(described_class.crc32('test', 3)).to eq(3402289634)
130
+ end
131
+
132
+ it 'raises RangeError for values too large' do
133
+ expect { described_class.crc32('test', 2**128) }.to raise_error(RangeError)
134
+ end
135
+ end
136
+
137
+ describe '.crc_table' do
138
+ it 'responds to crc_table' do
139
+ expect(described_class).to respond_to(:crc_table)
140
+ end
141
+
142
+ it 'returns an array' do
143
+ expect { described_class.crc_table }.not_to raise_error
144
+ expect(described_class.crc_table).to be_a(Array)
145
+ end
146
+ end
147
+
148
+ describe 'ZStreamFuncs struct' do
149
+ it 'is a ZStreamFuncs instance' do
150
+ expect(zstream_funcs).to be_a(described_class::ZStreamFuncs)
151
+ end
152
+
153
+ it 'responds to struct methods' do
154
+ expect(zstream_funcs).to respond_to(:reset)
155
+ expect(zstream_funcs).to respond_to(:end)
156
+ expect(zstream_funcs).to respond_to(:run)
157
+ end
158
+ end
159
+
160
+ describe 'error classes' do
161
+ it 'defines Error class' do
162
+ expect(described_class::Error).not_to be_nil
163
+ expect(described_class::Error.new).to be_a(StandardError)
164
+ end
165
+
166
+ it 'defines StreamEnd class' do
167
+ expect(described_class::StreamEnd).not_to be_nil
168
+ expect(described_class::StreamEnd.new).to be_a(described_class::Error)
169
+ end
170
+
171
+ it 'defines NeedDict class' do
172
+ expect(described_class::NeedDict.new).to be_a(described_class::Error)
173
+ end
174
+
175
+ it 'defines DataError class' do
176
+ expect(described_class::DataError.new).to be_a(described_class::Error)
177
+ end
178
+
179
+ it 'defines StreamError class' do
180
+ expect(described_class::StreamError.new).to be_a(described_class::Error)
181
+ end
182
+
183
+ it 'defines MemError class' do
184
+ expect(described_class::MemError.new).to be_a(described_class::Error)
185
+ end
186
+
187
+ it 'defines BufError class' do
188
+ expect(described_class::BufError.new).to be_a(described_class::Error)
189
+ end
190
+
191
+ it 'defines VersionError class' do
192
+ expect(described_class::VersionError.new).to be_a(described_class::Error)
193
+ end
194
+ end
195
+ end
data.tar.gz.sig CHANGED
Binary file