bzip2-ruby 0.2.3 → 0.2.4
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.
- data/README.rdoc +7 -0
- data/VERSION.yml +1 -1
- data/bzip2-ruby.gemspec +1 -1
- data/ext/bz2.c +14 -14
- data/test/reader.rb +41 -40
- data/test/writer.rb +28 -27
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -21,3 +21,10 @@ You may need to specify:
|
|
21
21
|
This extension module is copyrighted free software by Guy Decoux
|
22
22
|
You can redistribute it and/or modify it under the same term as Ruby.
|
23
23
|
Guy Decoux <ts@moulon.inra.fr>
|
24
|
+
|
25
|
+
== Modifications from origin version
|
26
|
+
|
27
|
+
* Switch to Jeweler
|
28
|
+
* Renamed BZ2 module/namespace to Bzip2
|
29
|
+
* Renamed compiled binary from "bz2" to "bzip2"
|
30
|
+
* Renamed gem from "bz2" to "bzip2-ruby"
|
data/VERSION.yml
CHANGED
data/bzip2-ruby.gemspec
CHANGED
data/ext/bz2.c
CHANGED
@@ -1473,9 +1473,9 @@ bz_proc_new(func, val)
|
|
1473
1473
|
|
1474
1474
|
void Init_bzip2()
|
1475
1475
|
{
|
1476
|
-
VALUE
|
1476
|
+
VALUE bz_mBzip2;
|
1477
1477
|
|
1478
|
-
if (rb_const_defined_at(rb_cObject, rb_intern("
|
1478
|
+
if (rb_const_defined_at(rb_cObject, rb_intern("Bzip2"))) {
|
1479
1479
|
rb_raise(rb_eNameError, "module already defined");
|
1480
1480
|
}
|
1481
1481
|
|
@@ -1494,20 +1494,20 @@ void Init_bzip2()
|
|
1494
1494
|
id_closed = rb_intern("closed?");
|
1495
1495
|
id_str = rb_intern("to_str");
|
1496
1496
|
|
1497
|
-
|
1498
|
-
bz_eConfigError = rb_define_class_under(
|
1499
|
-
bz_eError = rb_define_class_under(
|
1500
|
-
bz_eEOZError = rb_define_class_under(
|
1497
|
+
bz_mBzip2 = rb_define_module("Bzip2");
|
1498
|
+
bz_eConfigError = rb_define_class_under(bz_mBzip2, "ConfigError", rb_eFatal);
|
1499
|
+
bz_eError = rb_define_class_under(bz_mBzip2, "Error", rb_eIOError);
|
1500
|
+
bz_eEOZError = rb_define_class_under(bz_mBzip2, "EOZError", bz_eError);
|
1501
1501
|
|
1502
|
-
rb_define_module_function(
|
1503
|
-
rb_define_module_function(
|
1504
|
-
rb_define_module_function(
|
1505
|
-
rb_define_module_function(
|
1506
|
-
rb_define_module_function(
|
1502
|
+
rb_define_module_function(bz_mBzip2, "compress", bz_compress, -1);
|
1503
|
+
rb_define_module_function(bz_mBzip2, "uncompress", bz_uncompress, -1);
|
1504
|
+
rb_define_module_function(bz_mBzip2, "decompress", bz_uncompress, -1);
|
1505
|
+
rb_define_module_function(bz_mBzip2, "bzip2", bz_compress, -1);
|
1506
|
+
rb_define_module_function(bz_mBzip2, "bunzip2", bz_uncompress, -1);
|
1507
1507
|
/*
|
1508
1508
|
Writer
|
1509
1509
|
*/
|
1510
|
-
bz_cWriter = rb_define_class_under(
|
1510
|
+
bz_cWriter = rb_define_class_under(bz_mBzip2, "Writer", rb_cData);
|
1511
1511
|
#if HAVE_RB_DEFINE_ALLOC_FUNC
|
1512
1512
|
rb_define_alloc_func(bz_cWriter, bz_writer_s_alloc);
|
1513
1513
|
#else
|
@@ -1530,7 +1530,7 @@ void Init_bzip2()
|
|
1530
1530
|
/*
|
1531
1531
|
Reader
|
1532
1532
|
*/
|
1533
|
-
bz_cReader = rb_define_class_under(
|
1533
|
+
bz_cReader = rb_define_class_under(bz_mBzip2, "Reader", rb_cData);
|
1534
1534
|
rb_include_module(bz_cReader, rb_mEnumerable);
|
1535
1535
|
#if HAVE_RB_DEFINE_ALLOC_FUNC
|
1536
1536
|
rb_define_alloc_func(bz_cReader, bz_reader_s_alloc);
|
@@ -1570,7 +1570,7 @@ void Init_bzip2()
|
|
1570
1570
|
/*
|
1571
1571
|
Internal
|
1572
1572
|
*/
|
1573
|
-
bz_cInternal = rb_define_class_under(
|
1573
|
+
bz_cInternal = rb_define_class_under(bz_mBzip2, "InternalStr", rb_cData);
|
1574
1574
|
#if HAVE_RB_DEFINE_ALLOC_FUNC
|
1575
1575
|
rb_undef_alloc_func(bz_cInternal);
|
1576
1576
|
#else
|
data/test/reader.rb
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
# This is the test from rubicon
|
4
4
|
|
5
5
|
$LOAD_PATH.unshift(*%w{.. tests})
|
6
|
-
require '
|
6
|
+
require 'rubygems'
|
7
|
+
require 'bzip2'
|
7
8
|
require 'runit_'
|
8
9
|
|
9
10
|
Inh = defined?(RUNIT) ? RUNIT : Test::Unit
|
@@ -32,7 +33,7 @@ class TestReader < Inh::TestCase
|
|
32
33
|
|
33
34
|
def test_f_s_foreach
|
34
35
|
count = 0
|
35
|
-
|
36
|
+
Bzip2::Reader.foreach($file) do |line|
|
36
37
|
num = line[0..1].to_i
|
37
38
|
assert_equal(count, num)
|
38
39
|
count += 1
|
@@ -40,7 +41,7 @@ class TestReader < Inh::TestCase
|
|
40
41
|
assert_equal($data.size, count)
|
41
42
|
|
42
43
|
count = 0
|
43
|
-
|
44
|
+
Bzip2::Reader.foreach($file, nil) do |file|
|
44
45
|
file.split(/\n/).each do |line|
|
45
46
|
num = line[0..1].to_i
|
46
47
|
assert_equal(count, num)
|
@@ -50,23 +51,23 @@ class TestReader < Inh::TestCase
|
|
50
51
|
assert_equal($data.size, count)
|
51
52
|
|
52
53
|
count = 0
|
53
|
-
|
54
|
+
Bzip2::Reader.foreach($file, ' ') do |thing|
|
54
55
|
count += 1
|
55
56
|
end
|
56
57
|
assert_equal(41, count)
|
57
58
|
end
|
58
59
|
|
59
60
|
def test_f_s_readlines
|
60
|
-
lines =
|
61
|
+
lines = Bzip2::Reader.readlines($file)
|
61
62
|
assert_equal($data.size, lines.size)
|
62
63
|
|
63
|
-
lines =
|
64
|
+
lines = Bzip2::Reader.readlines($file, nil)
|
64
65
|
assert_equal(1, lines.size)
|
65
66
|
assert_equal(SAMPLE.length * $data.size, lines[0].size)
|
66
67
|
end
|
67
68
|
|
68
69
|
def test_f_closed?
|
69
|
-
f =
|
70
|
+
f = Bzip2::Reader.open($file)
|
70
71
|
assert(!f.closed?)
|
71
72
|
f.close
|
72
73
|
assert(f.closed?)
|
@@ -74,7 +75,7 @@ class TestReader < Inh::TestCase
|
|
74
75
|
|
75
76
|
def test_f_each
|
76
77
|
count = 0
|
77
|
-
|
78
|
+
Bzip2::Reader.open($file) do |file|
|
78
79
|
file.each do |line|
|
79
80
|
num = line[0..1].to_i
|
80
81
|
assert_equal(count, num)
|
@@ -84,7 +85,7 @@ class TestReader < Inh::TestCase
|
|
84
85
|
end
|
85
86
|
|
86
87
|
count = 0
|
87
|
-
|
88
|
+
Bzip2::Reader.open($file) do |file|
|
88
89
|
file.each(nil) do |contents|
|
89
90
|
contents.split(/\n/).each do |line|
|
90
91
|
num = line[0..1].to_i
|
@@ -96,7 +97,7 @@ class TestReader < Inh::TestCase
|
|
96
97
|
assert_equal($data.size, count)
|
97
98
|
|
98
99
|
count = 0
|
99
|
-
|
100
|
+
Bzip2::Reader.open($file) do |file|
|
100
101
|
file.each(' ') do |thing|
|
101
102
|
count += 1
|
102
103
|
end
|
@@ -108,7 +109,7 @@ class TestReader < Inh::TestCase
|
|
108
109
|
count = 0
|
109
110
|
data = $data.join
|
110
111
|
|
111
|
-
|
112
|
+
Bzip2::Reader.open($file) do |file|
|
112
113
|
file.each_byte do |b|
|
113
114
|
assert_equal(data[count], b)
|
114
115
|
count += 1
|
@@ -119,7 +120,7 @@ class TestReader < Inh::TestCase
|
|
119
120
|
|
120
121
|
def test_f_each_line
|
121
122
|
count = 0
|
122
|
-
|
123
|
+
Bzip2::Reader.open($file) do |file|
|
123
124
|
file.each_line do |line|
|
124
125
|
num = line[0..1].to_i
|
125
126
|
assert_equal(count, num)
|
@@ -129,7 +130,7 @@ class TestReader < Inh::TestCase
|
|
129
130
|
end
|
130
131
|
|
131
132
|
count = 0
|
132
|
-
|
133
|
+
Bzip2::Reader.open($file) do |file|
|
133
134
|
file.each_line(nil) do |contents|
|
134
135
|
contents.split(/\n/).each do |line|
|
135
136
|
num = line[0..1].to_i
|
@@ -141,7 +142,7 @@ class TestReader < Inh::TestCase
|
|
141
142
|
assert_equal($data.size, count)
|
142
143
|
|
143
144
|
count = 0
|
144
|
-
|
145
|
+
Bzip2::Reader.open($file) do |file|
|
145
146
|
file.each_line(' ') do |thing|
|
146
147
|
count += 1
|
147
148
|
end
|
@@ -150,7 +151,7 @@ class TestReader < Inh::TestCase
|
|
150
151
|
end
|
151
152
|
|
152
153
|
def test_f_eof
|
153
|
-
|
154
|
+
Bzip2::Reader.open($file) do |file|
|
154
155
|
$data.size.times do
|
155
156
|
assert(!file.eof)
|
156
157
|
assert(!file.eof?)
|
@@ -165,7 +166,7 @@ class TestReader < Inh::TestCase
|
|
165
166
|
count = 0
|
166
167
|
data = $data.join
|
167
168
|
|
168
|
-
|
169
|
+
Bzip2::Reader.open($file) do |file|
|
169
170
|
while (ch = file.getc)
|
170
171
|
assert_equal(data[count], ch)
|
171
172
|
count += 1
|
@@ -177,7 +178,7 @@ class TestReader < Inh::TestCase
|
|
177
178
|
|
178
179
|
def test_f_gets
|
179
180
|
count = 0
|
180
|
-
|
181
|
+
Bzip2::Reader.open($file) do |file|
|
181
182
|
while (line = file.gets)
|
182
183
|
num = line[0..1].to_i
|
183
184
|
assert_equal(count, num)
|
@@ -188,7 +189,7 @@ class TestReader < Inh::TestCase
|
|
188
189
|
end
|
189
190
|
|
190
191
|
count = 0
|
191
|
-
|
192
|
+
Bzip2::Reader.open($file) do |file|
|
192
193
|
while (line = file.gets("line\n"))
|
193
194
|
assert_equal($data[count], line)
|
194
195
|
num = line[0..1].to_i
|
@@ -200,7 +201,7 @@ class TestReader < Inh::TestCase
|
|
200
201
|
end
|
201
202
|
|
202
203
|
count = 0
|
203
|
-
|
204
|
+
Bzip2::Reader.open($file) do |file|
|
204
205
|
while (contents = file.gets(nil))
|
205
206
|
contents.split(/\n/).each do |line|
|
206
207
|
num = line[0..1].to_i
|
@@ -212,7 +213,7 @@ class TestReader < Inh::TestCase
|
|
212
213
|
assert_equal($data.size, count)
|
213
214
|
|
214
215
|
count = 0
|
215
|
-
|
216
|
+
Bzip2::Reader.open($file) do |file|
|
216
217
|
while (thing = file.gets(' '))
|
217
218
|
count += 1
|
218
219
|
end
|
@@ -221,7 +222,7 @@ class TestReader < Inh::TestCase
|
|
221
222
|
end
|
222
223
|
|
223
224
|
def test_f_read
|
224
|
-
|
225
|
+
Bzip2::Reader.open($file) do |file|
|
225
226
|
content = file.read
|
226
227
|
assert_equal(SAMPLE.length * $data.size, content.length)
|
227
228
|
count = 0
|
@@ -232,7 +233,7 @@ class TestReader < Inh::TestCase
|
|
232
233
|
end
|
233
234
|
end
|
234
235
|
|
235
|
-
|
236
|
+
Bzip2::Reader.open($file) do |file|
|
236
237
|
assert_equal("00: This is ", file.read(12))
|
237
238
|
assert_equal("a line\n01: T", file.read(12))
|
238
239
|
end
|
@@ -241,57 +242,57 @@ class TestReader < Inh::TestCase
|
|
241
242
|
def test_f_readchar
|
242
243
|
count = 0
|
243
244
|
data = $data.join
|
244
|
-
|
245
|
+
Bzip2::Reader.open($file) do |file|
|
245
246
|
190.times do |count|
|
246
247
|
ch = file.readchar
|
247
248
|
assert_equal(data[count], ch)
|
248
249
|
count += 1
|
249
250
|
end
|
250
|
-
assert_raises(
|
251
|
+
assert_raises(Bzip2::EOZError) { file.readchar }
|
251
252
|
end
|
252
253
|
end
|
253
254
|
|
254
255
|
def test_f_readline
|
255
256
|
count = 0
|
256
|
-
|
257
|
+
Bzip2::Reader.open($file) do |file|
|
257
258
|
$data.size.times do |count|
|
258
259
|
line = file.readline
|
259
260
|
num = line[0..1].to_i
|
260
261
|
assert_equal(count, num)
|
261
262
|
count += 1
|
262
263
|
end
|
263
|
-
assert_raises(
|
264
|
+
assert_raises(Bzip2::EOZError) { file.readline }
|
264
265
|
end
|
265
266
|
|
266
267
|
count = 0
|
267
|
-
|
268
|
+
Bzip2::Reader.open($file) do |file|
|
268
269
|
contents = file.readline(nil)
|
269
270
|
contents.split(/\n/).each do |line|
|
270
271
|
num = line[0..1].to_i
|
271
272
|
assert_equal(count, num)
|
272
273
|
count += 1
|
273
274
|
end
|
274
|
-
assert_raises(
|
275
|
+
assert_raises(Bzip2::EOZError) { file.readline }
|
275
276
|
end
|
276
277
|
assert_equal($data.size, count)
|
277
278
|
|
278
279
|
count = 0
|
279
|
-
|
280
|
+
Bzip2::Reader.open($file) do |file|
|
280
281
|
41.times do |count|
|
281
282
|
thing = file.readline(' ')
|
282
283
|
count += 1
|
283
284
|
end
|
284
|
-
assert_raises(
|
285
|
+
assert_raises(Bzip2::EOZError) { file.readline }
|
285
286
|
end
|
286
287
|
end
|
287
288
|
|
288
289
|
def test_f_readlines
|
289
|
-
|
290
|
+
Bzip2::Reader.open($file) do |file|
|
290
291
|
lines = file.readlines
|
291
292
|
assert_equal($data.size, lines.size)
|
292
293
|
end
|
293
294
|
|
294
|
-
|
295
|
+
Bzip2::Reader.open($file) do |file|
|
295
296
|
lines = file.readlines(nil)
|
296
297
|
assert_equal(1, lines.size)
|
297
298
|
assert_equal(SAMPLE.length * $data.size, lines[0].size)
|
@@ -299,7 +300,7 @@ class TestReader < Inh::TestCase
|
|
299
300
|
end
|
300
301
|
|
301
302
|
def test_f_ungetc
|
302
|
-
|
303
|
+
Bzip2::Reader.open($file) do |file|
|
303
304
|
assert_equal(?0, file.getc)
|
304
305
|
assert_equal(?0, file.getc)
|
305
306
|
assert_equal(?:, file.getc)
|
@@ -314,7 +315,7 @@ class TestReader < Inh::TestCase
|
|
314
315
|
|
315
316
|
def test_f_ungets
|
316
317
|
count = 0
|
317
|
-
|
318
|
+
Bzip2::Reader.open($file) do |file|
|
318
319
|
assert_equal($data[count], file.gets)
|
319
320
|
assert_equal(count + 1, file.lineno);
|
320
321
|
assert_nil(file.ungets($data[count]))
|
@@ -326,35 +327,35 @@ class TestReader < Inh::TestCase
|
|
326
327
|
def test_s_readline
|
327
328
|
count = 0
|
328
329
|
string = IO.readlines($file, nil)[0]
|
329
|
-
file =
|
330
|
+
file = Bzip2::Reader.new(string)
|
330
331
|
$data.size.times do |count|
|
331
332
|
line = file.readline
|
332
333
|
num = line[0..1].to_i
|
333
334
|
assert_equal(count, num)
|
334
335
|
count += 1
|
335
336
|
end
|
336
|
-
assert_raises(
|
337
|
+
assert_raises(Bzip2::EOZError) { file.readline }
|
337
338
|
file.close
|
338
339
|
|
339
340
|
count = 0
|
340
|
-
file =
|
341
|
+
file = Bzip2::Reader.new(string)
|
341
342
|
contents = file.readline(nil)
|
342
343
|
contents.split(/\n/).each do |line|
|
343
344
|
num = line[0..1].to_i
|
344
345
|
assert_equal(count, num)
|
345
346
|
count += 1
|
346
347
|
end
|
347
|
-
assert_raises(
|
348
|
+
assert_raises(Bzip2::EOZError) { file.readline }
|
348
349
|
assert_equal($data.size, count)
|
349
350
|
file.close
|
350
351
|
|
351
352
|
count = 0
|
352
|
-
file =
|
353
|
+
file = Bzip2::Reader.new(string)
|
353
354
|
41.times do |count|
|
354
355
|
thing = file.readline(' ')
|
355
356
|
count += 1
|
356
357
|
end
|
357
|
-
assert_raises(
|
358
|
+
assert_raises(Bzip2::EOZError) { file.readline }
|
358
359
|
file.close
|
359
360
|
end
|
360
361
|
|
data/test/writer.rb
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
# This is the test from rubicon
|
4
4
|
|
5
5
|
$LOAD_PATH.unshift(*%w{.. tests})
|
6
|
-
require '
|
6
|
+
require 'rubygems'
|
7
|
+
require 'bzip2'
|
7
8
|
require 'runit_'
|
8
9
|
|
9
10
|
Inh = defined?(RUNIT) ? RUNIT : Test::Unit
|
@@ -19,11 +20,11 @@ end
|
|
19
20
|
class TestWriter < Inh::TestCase
|
20
21
|
|
21
22
|
def test_f_LSHIFT # '<<'
|
22
|
-
|
23
|
+
Bzip2::Writer.open($file, "w") do |file|
|
23
24
|
file << 1 << "\n" << Dummy.new << "\n" << "cat\n"
|
24
25
|
end
|
25
26
|
expected = [ "1\n", "dummy\n", "cat\n"]
|
26
|
-
|
27
|
+
Bzip2::Reader.foreach($file) do |line|
|
27
28
|
assert_equal(expected.shift, line)
|
28
29
|
end
|
29
30
|
assert_equal([], expected)
|
@@ -31,21 +32,21 @@ class TestWriter < Inh::TestCase
|
|
31
32
|
|
32
33
|
def test_f_error
|
33
34
|
io = File.new($file, "w")
|
34
|
-
bz2 =
|
35
|
+
bz2 = Bzip2::Writer.new(io)
|
35
36
|
bz2 << 1 << "\n" << Dummy.new << "\n" << "cat\n"
|
36
|
-
bz =
|
37
|
-
assert_raises(
|
38
|
-
bz =
|
39
|
-
assert_raises(
|
37
|
+
bz = Bzip2::Reader.new($file)
|
38
|
+
assert_raises(Bzip2::Error) { bz.gets }
|
39
|
+
bz = Bzip2::Reader.open($file)
|
40
|
+
assert_raises(Bzip2::EOZError) { bz.gets }
|
40
41
|
io.close
|
41
|
-
assert_raises(IOError) {
|
42
|
+
assert_raises(IOError) { Bzip2::Reader.new(io) }
|
42
43
|
end
|
43
44
|
|
44
45
|
def test_f_gets_para
|
45
|
-
|
46
|
+
Bzip2::Writer.open($file) do |file|
|
46
47
|
file.print "foo\n"*4096, "\n"*4096, "bar"*4096, "\n"*4096, "zot\n"*1024
|
47
48
|
end
|
48
|
-
|
49
|
+
Bzip2::Reader.open($file) do |file|
|
49
50
|
assert_equal("foo\n"*4096+"\n", file.gets(""))
|
50
51
|
assert_equal("bar"*4096+"\n\n", file.gets(""))
|
51
52
|
assert_equal("zot\n"*1024, file.gets(""))
|
@@ -53,7 +54,7 @@ class TestWriter < Inh::TestCase
|
|
53
54
|
end
|
54
55
|
|
55
56
|
def test_f_print
|
56
|
-
|
57
|
+
Bzip2::Writer.open($file) do |file|
|
57
58
|
file.print "hello"
|
58
59
|
file.print 1,2
|
59
60
|
$_ = "wombat\n"
|
@@ -67,31 +68,31 @@ class TestWriter < Inh::TestCase
|
|
67
68
|
$, = nil
|
68
69
|
end
|
69
70
|
|
70
|
-
|
71
|
+
Bzip2::Reader.open($file) do |file|
|
71
72
|
content = file.gets(nil)
|
72
73
|
assert_equal("hello12wombat\n3,4:5,6:\n", content)
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
76
77
|
def test_f_putc
|
77
|
-
|
78
|
+
Bzip2::Writer.open($file, "wb") do |file|
|
78
79
|
file.putc "A"
|
79
80
|
0.upto(255) { |ch| file.putc ch }
|
80
81
|
end
|
81
82
|
|
82
|
-
|
83
|
+
Bzip2::Reader.open($file, "rb") do |file|
|
83
84
|
assert_equal(?A, file.getc)
|
84
85
|
0.upto(255) { |ch| assert_equal(ch, file.getc) }
|
85
86
|
end
|
86
87
|
end
|
87
88
|
|
88
89
|
def test_f_puts
|
89
|
-
|
90
|
+
Bzip2::Writer.open($file, "w") do |file|
|
90
91
|
file.puts "line 1", "line 2"
|
91
92
|
file.puts [ Dummy.new, 4 ]
|
92
93
|
end
|
93
94
|
|
94
|
-
|
95
|
+
Bzip2::Reader.open($file) do |file|
|
95
96
|
assert_equal("line 1\n", file.gets)
|
96
97
|
assert_equal("line 2\n", file.gets)
|
97
98
|
assert_equal("dummy\n", file.gets)
|
@@ -100,7 +101,7 @@ class TestWriter < Inh::TestCase
|
|
100
101
|
end
|
101
102
|
|
102
103
|
def test_f_write
|
103
|
-
|
104
|
+
Bzip2::Writer.open($file, "w") do |file|
|
104
105
|
assert_equal(10, file.write('*' * 10))
|
105
106
|
assert_equal(5, file.write('!' * 5))
|
106
107
|
assert_equal(0, file.write(''))
|
@@ -109,33 +110,33 @@ class TestWriter < Inh::TestCase
|
|
109
110
|
assert_equal(1, file.write("\n"))
|
110
111
|
end
|
111
112
|
|
112
|
-
|
113
|
+
Bzip2::Reader.open($file) do |file|
|
113
114
|
assert_equal("**********!!!!!12.3\n", file.gets)
|
114
115
|
end
|
115
116
|
end
|
116
117
|
|
117
118
|
def test_s_string
|
118
|
-
file =
|
119
|
+
file = Bzip2::Writer.new
|
119
120
|
assert_equal(10, file.write('*' * 10))
|
120
121
|
assert_equal(5, file.write('!' * 5))
|
121
122
|
assert_equal(0, file.write(''))
|
122
123
|
assert_equal(1, file.write(1))
|
123
124
|
assert_equal(3, file.write(2.30000))
|
124
125
|
assert_equal(1, file.write("\n"))
|
125
|
-
line =
|
126
|
+
line = Bzip2::bunzip2(file.flush)
|
126
127
|
assert_equal("**********!!!!!12.3\n", line)
|
127
128
|
|
128
|
-
line =
|
129
|
+
line = Bzip2::bunzip2(Bzip2::bzip2("**********!!!!!12.3\n"))
|
129
130
|
assert_equal("**********!!!!!12.3\n", line)
|
130
131
|
|
131
132
|
test = "foo\n"*4096 + "\n"*4096 + "bar"*4096 + "\n"*4096 + "zot\n"*1024
|
132
|
-
line =
|
133
|
+
line = Bzip2::bunzip2(Bzip2::bzip2(test))
|
133
134
|
assert_equal(test, line)
|
134
135
|
|
135
|
-
assert(
|
136
|
-
assert(
|
137
|
-
assert(!
|
138
|
-
assert(!
|
136
|
+
assert(Bzip2::bzip2("aaaaaaaaa".taint).tainted?)
|
137
|
+
assert(Bzip2::bunzip2(Bzip2::bzip2("aaaaaaaaa".taint)).tainted?)
|
138
|
+
assert(!Bzip2::bzip2("aaaaaaaaa").tainted?)
|
139
|
+
assert(!Bzip2::bunzip2(Bzip2::bzip2("aaaaaaaaa")).tainted?)
|
139
140
|
|
140
141
|
end
|
141
142
|
|