|
12 | 12 | end
|
13 | 13 |
|
14 | 14 | if defined? Zlib
|
15 |
| - child_env = {} |
16 |
| - child_env['DFLTCC'] = '0' if RUBY_PLATFORM =~ /s390x/ |
17 |
| - Zlib::CHILD_ENV = child_env.freeze |
18 |
| - |
19 | 15 | class TestZlibDeflate < Test::Unit::TestCase
|
20 | 16 | def test_initialize
|
21 | 17 | z = Zlib::Deflate.new
|
@@ -48,63 +44,59 @@ def test_deflate
|
48 | 44 | end
|
49 | 45 |
|
50 | 46 | def test_deflate_chunked
|
51 |
| - assert_separately([Zlib::CHILD_ENV, '-rzlib'], <<~'end;') |
52 |
| - original = ''.dup |
53 |
| - chunks = [] |
54 |
| - r = Random.new 0 |
55 |
| -
|
56 |
| - z = Zlib::Deflate.new |
57 |
| -
|
58 |
| - 2.times do |
59 |
| - input = r.bytes(20000) |
60 |
| - original << input |
61 |
| - z.deflate(input) do |chunk| |
62 |
| - chunks << chunk |
63 |
| - end |
| 47 | + original = ''.dup |
| 48 | + chunks = [] |
| 49 | + r = Random.new 0 |
| 50 | + |
| 51 | + z = Zlib::Deflate.new |
| 52 | + |
| 53 | + 2.times do |
| 54 | + input = r.bytes(20000) |
| 55 | + original << input |
| 56 | + z.deflate(input) do |chunk| |
| 57 | + chunks << chunk |
64 | 58 | end
|
| 59 | + end |
65 | 60 |
|
66 |
| - assert_equal [16384, 16384], |
67 |
| - chunks.map { |chunk| chunk.length } |
| 61 | + assert_equal [16384, 16384], |
| 62 | + chunks.map { |chunk| chunk.length } |
68 | 63 |
|
69 |
| - final = z.finish |
| 64 | + final = z.finish |
70 | 65 |
|
71 |
| - assert_equal 7253, final.length |
| 66 | + assert_equal 7253, final.length |
72 | 67 |
|
73 |
| - chunks << final |
74 |
| - all = chunks.join |
| 68 | + chunks << final |
| 69 | + all = chunks.join |
75 | 70 |
|
76 |
| - inflated = Zlib.inflate all |
| 71 | + inflated = Zlib.inflate all |
77 | 72 |
|
78 |
| - assert_equal original, inflated |
79 |
| - end; |
| 73 | + assert_equal original, inflated |
80 | 74 | end
|
81 | 75 |
|
82 | 76 | def test_deflate_chunked_break
|
83 |
| - assert_separately([Zlib::CHILD_ENV, '-rzlib'], <<~'end;') |
84 |
| - chunks = [] |
85 |
| - r = Random.new 0 |
| 77 | + chunks = [] |
| 78 | + r = Random.new 0 |
86 | 79 |
|
87 |
| - z = Zlib::Deflate.new |
| 80 | + z = Zlib::Deflate.new |
88 | 81 |
|
89 |
| - input = r.bytes(20000) |
90 |
| - z.deflate(input) do |chunk| |
91 |
| - chunks << chunk |
92 |
| - break |
93 |
| - end |
| 82 | + input = r.bytes(20000) |
| 83 | + z.deflate(input) do |chunk| |
| 84 | + chunks << chunk |
| 85 | + break |
| 86 | + end |
94 | 87 |
|
95 |
| - assert_equal [16384], chunks.map { |chunk| chunk.length } |
| 88 | + assert_equal [16384], chunks.map { |chunk| chunk.length } |
96 | 89 |
|
97 |
| - final = z.finish |
| 90 | + final = z.finish |
98 | 91 |
|
99 |
| - assert_equal 3632, final.length |
| 92 | + assert_equal 3632, final.length |
100 | 93 |
|
101 |
| - all = chunks.join |
102 |
| - all << final |
| 94 | + all = chunks.join |
| 95 | + all << final |
103 | 96 |
|
104 |
| - original = Zlib.inflate all |
| 97 | + original = Zlib.inflate all |
105 | 98 |
|
106 |
| - assert_equal input, original |
107 |
| - end; |
| 99 | + assert_equal input, original |
108 | 100 | end
|
109 | 101 |
|
110 | 102 | def test_addstr
|
@@ -960,32 +952,30 @@ def test_unused
|
960 | 952 | end
|
961 | 953 |
|
962 | 954 | def test_unused2
|
963 |
| - assert_separately([Zlib::CHILD_ENV, '-rzlib', '-rstringio'], <<~'end;') |
964 |
| - zio = StringIO.new |
| 955 | + zio = StringIO.new |
965 | 956 |
|
966 |
| - io = Zlib::GzipWriter.new zio |
967 |
| - io.write 'aaaa' |
968 |
| - io.finish |
| 957 | + io = Zlib::GzipWriter.new zio |
| 958 | + io.write 'aaaa' |
| 959 | + io.finish |
969 | 960 |
|
970 |
| - io = Zlib::GzipWriter.new zio |
971 |
| - io.write 'bbbb' |
972 |
| - io.finish |
| 961 | + io = Zlib::GzipWriter.new zio |
| 962 | + io.write 'bbbb' |
| 963 | + io.finish |
973 | 964 |
|
974 |
| - zio.rewind |
| 965 | + zio.rewind |
975 | 966 |
|
976 |
| - io = Zlib::GzipReader.new zio |
977 |
| - assert_equal('aaaa', io.read) |
978 |
| - unused = io.unused |
979 |
| - assert_equal(24, unused.bytesize) |
980 |
| - io.finish |
| 967 | + io = Zlib::GzipReader.new zio |
| 968 | + assert_equal('aaaa', io.read) |
| 969 | + unused = io.unused |
| 970 | + assert_equal(24, unused.bytesize) |
| 971 | + io.finish |
981 | 972 |
|
982 |
| - zio.pos -= unused.length |
| 973 | + zio.pos -= unused.length |
983 | 974 |
|
984 |
| - io = Zlib::GzipReader.new zio |
985 |
| - assert_equal('bbbb', io.read) |
986 |
| - assert_equal(nil, io.unused) |
987 |
| - io.finish |
988 |
| - end; |
| 975 | + io = Zlib::GzipReader.new zio |
| 976 | + assert_equal('bbbb', io.read) |
| 977 | + assert_equal(nil, io.unused) |
| 978 | + io.finish |
989 | 979 | end
|
990 | 980 |
|
991 | 981 | def test_read
|
@@ -1412,46 +1402,36 @@ def test_deflate
|
1412 | 1402 | end
|
1413 | 1403 |
|
1414 | 1404 | def test_deflate_stream
|
1415 |
| - assert_separately([Zlib::CHILD_ENV, '-rzlib'], <<~'end;') |
1416 |
| - r = Random.new 0 |
| 1405 | + r = Random.new 0 |
1417 | 1406 |
|
1418 |
| - deflated = ''.dup |
| 1407 | + deflated = ''.dup |
1419 | 1408 |
|
1420 |
| - Zlib.deflate(r.bytes(20000)) do |chunk| |
1421 |
| - deflated << chunk |
1422 |
| - end |
| 1409 | + Zlib.deflate(r.bytes(20000)) do |chunk| |
| 1410 | + deflated << chunk |
| 1411 | + end |
1423 | 1412 |
|
1424 |
| - assert_equal 20016, deflated.length |
1425 |
| - end; |
| 1413 | + assert_equal 20016, deflated.length |
1426 | 1414 | end
|
1427 | 1415 |
|
1428 | 1416 | def test_gzip
|
1429 |
| - assert_separately([Zlib::CHILD_ENV, '-rzlib'], <<~'end;') |
1430 |
| - actual = Zlib.gzip("foo".freeze) |
1431 |
| - actual[4, 4] = "\x00\x00\x00\x00" # replace mtime |
1432 |
| - actual[9] = "\xff" # replace OS |
1433 |
| - expected = %w[1f8b08000000000000ff4bcbcf07002165738c03000000].pack("H*") |
1434 |
| - assert_equal expected, actual |
1435 |
| - end; |
1436 |
| - end |
| 1417 | + actual = Zlib.gzip("foo".freeze) |
| 1418 | + actual[4, 4] = "\x00\x00\x00\x00" # replace mtime |
| 1419 | + actual[9] = "\xff" # replace OS |
| 1420 | + expected = %w[1f8b08000000000000ff4bcbcf07002165738c03000000].pack("H*") |
| 1421 | + assert_equal expected, actual |
1437 | 1422 |
|
1438 |
| - def test_gzip_level_0 |
1439 | 1423 | actual = Zlib.gzip("foo".freeze, level: 0)
|
1440 | 1424 | actual[4, 4] = "\x00\x00\x00\x00" # replace mtime
|
1441 | 1425 | actual[9] = "\xff" # replace OS
|
1442 | 1426 | expected = %w[1f8b08000000000000ff010300fcff666f6f2165738c03000000].pack("H*")
|
1443 | 1427 | assert_equal expected, actual
|
1444 |
| - end |
1445 | 1428 |
|
1446 |
| - def test_gzip_level_9 |
1447 | 1429 | actual = Zlib.gzip("foo".freeze, level: 9)
|
1448 | 1430 | actual[4, 4] = "\x00\x00\x00\x00" # replace mtime
|
1449 | 1431 | actual[9] = "\xff" # replace OS
|
1450 | 1432 | expected = %w[1f8b08000000000002ff4bcbcf07002165738c03000000].pack("H*")
|
1451 | 1433 | assert_equal expected, actual
|
1452 |
| - end |
1453 | 1434 |
|
1454 |
| - def test_gzip_level_9_filtered |
1455 | 1435 | actual = Zlib.gzip("foo".freeze, level: 9, strategy: Zlib::FILTERED)
|
1456 | 1436 | actual[4, 4] = "\x00\x00\x00\x00" # replace mtime
|
1457 | 1437 | actual[9] = "\xff" # replace OS
|
|
0 commit comments