zliby 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/CHANGES +5 -0
  2. data/LICENSE +26 -0
  3. data/README +33 -0
  4. data/TODO +6 -0
  5. data/bin/zliber +7 -0
  6. data/lib/zliby.rb +624 -0
  7. data/specs/adler32_spec.rb +46 -0
  8. data/specs/crc32_spec.rb +52 -0
  9. data/specs/crc_table_spec.rb +11 -0
  10. data/specs/deflate/append_spec.rb +2 -0
  11. data/specs/deflate/deflate_spec.rb +49 -0
  12. data/specs/deflate/flush_spec.rb +2 -0
  13. data/specs/deflate/initialize_copy_spec.rb +2 -0
  14. data/specs/deflate/new_spec.rb +2 -0
  15. data/specs/deflate/params_spec.rb +21 -0
  16. data/specs/deflate/set_dictionary_spec.rb +14 -0
  17. data/specs/gzipfile/close_spec.rb +23 -0
  18. data/specs/gzipfile/closed_spec.rb +18 -0
  19. data/specs/gzipfile/comment_spec.rb +28 -0
  20. data/specs/gzipfile/crc_spec.rb +2 -0
  21. data/specs/gzipfile/finish_spec.rb +2 -0
  22. data/specs/gzipfile/level_spec.rb +2 -0
  23. data/specs/gzipfile/mtime_spec.rb +2 -0
  24. data/specs/gzipfile/orig_name_spec.rb +28 -0
  25. data/specs/gzipfile/os_code_spec.rb +2 -0
  26. data/specs/gzipfile/sync_spec.rb +2 -0
  27. data/specs/gzipfile/to_io_spec.rb +2 -0
  28. data/specs/gzipfile/wrap_spec.rb +2 -0
  29. data/specs/gzipreader/each_byte_spec.rb +2 -0
  30. data/specs/gzipreader/each_line_spec.rb +2 -0
  31. data/specs/gzipreader/each_spec.rb +2 -0
  32. data/specs/gzipreader/eof_spec.rb +23 -0
  33. data/specs/gzipreader/getc_spec.rb +2 -0
  34. data/specs/gzipreader/gets_spec.rb +2 -0
  35. data/specs/gzipreader/lineno_spec.rb +2 -0
  36. data/specs/gzipreader/new_spec.rb +2 -0
  37. data/specs/gzipreader/open_spec.rb +2 -0
  38. data/specs/gzipreader/pos_spec.rb +27 -0
  39. data/specs/gzipreader/read_spec.rb +29 -0
  40. data/specs/gzipreader/readchar_spec.rb +2 -0
  41. data/specs/gzipreader/readline_spec.rb +2 -0
  42. data/specs/gzipreader/readlines_spec.rb +2 -0
  43. data/specs/gzipreader/rewind_spec.rb +34 -0
  44. data/specs/gzipreader/tell_spec.rb +2 -0
  45. data/specs/gzipreader/ungetc_spec.rb +2 -0
  46. data/specs/gzipreader/unused_spec.rb +2 -0
  47. data/specs/gzipwriter/append_spec.rb +2 -0
  48. data/specs/gzipwriter/comment_spec.rb +2 -0
  49. data/specs/gzipwriter/flush_spec.rb +2 -0
  50. data/specs/gzipwriter/mtime_spec.rb +42 -0
  51. data/specs/gzipwriter/new_spec.rb +2 -0
  52. data/specs/gzipwriter/open_spec.rb +2 -0
  53. data/specs/gzipwriter/orig_name_spec.rb +2 -0
  54. data/specs/gzipwriter/pos_spec.rb +2 -0
  55. data/specs/gzipwriter/print_spec.rb +2 -0
  56. data/specs/gzipwriter/printf_spec.rb +2 -0
  57. data/specs/gzipwriter/putc_spec.rb +2 -0
  58. data/specs/gzipwriter/puts_spec.rb +2 -0
  59. data/specs/gzipwriter/tell_spec.rb +2 -0
  60. data/specs/gzipwriter/write_spec.rb +23 -0
  61. data/specs/inflate/append_spec.rb +12 -0
  62. data/specs/inflate/inflate_spec.rb +49 -0
  63. data/specs/inflate/new_spec.rb +2 -0
  64. data/specs/inflate/set_dictionary_spec.rb +20 -0
  65. data/specs/inflate/sync_point_spec.rb +2 -0
  66. data/specs/inflate/sync_spec.rb +2 -0
  67. data/specs/zlib_version_spec.rb +2 -0
  68. data/specs/zstream/adler_spec.rb +1 -0
  69. data/specs/zstream/avail_in_spec.rb +1 -0
  70. data/specs/zstream/avail_out_spec.rb +1 -0
  71. data/specs/zstream/close_spec.rb +2 -0
  72. data/specs/zstream/closed_spec.rb +2 -0
  73. data/specs/zstream/data_type_spec.rb +2 -0
  74. data/specs/zstream/end_spec.rb +2 -0
  75. data/specs/zstream/ended_spec.rb +2 -0
  76. data/specs/zstream/finish_spec.rb +2 -0
  77. data/specs/zstream/finished_spec.rb +2 -0
  78. data/specs/zstream/flush_next_in_spec.rb +2 -0
  79. data/specs/zstream/flush_next_out_spec.rb +16 -0
  80. data/specs/zstream/reset_spec.rb +2 -0
  81. data/specs/zstream/stream_end_spec.rb +2 -0
  82. data/specs/zstream/total_in_spec.rb +2 -0
  83. data/specs/zstream/total_out_spec.rb +2 -0
  84. metadata +137 -0
@@ -0,0 +1,46 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+
4
+ describe "Zlib.adler32" do
5
+ it "calculates Adler checksum for string" do
6
+ Zlib.adler32("").should == 1
7
+ Zlib.adler32(" ").should == 2162721
8
+ Zlib.adler32("123456789").should == 152961502
9
+ Zlib.adler32("!@#\{$\}%^&**()").should == 365495023
10
+ Zlib.adler32("to be or not to be" * 22).should == 3979904837
11
+ Zlib.adler32("0").should == 3211313
12
+ Zlib.adler32((2**32).to_s).should == 193331739
13
+ Zlib.adler32((2**64).to_s).should == 723452953
14
+ end
15
+
16
+ it "calculates Adler checksum for string and initial Adler value" do
17
+ test_string = "This is a test string! How exciting!%?"
18
+ Zlib.adler32(test_string, 0).should == 63900955
19
+ Zlib.adler32(test_string, 1).should == 66391324
20
+ Zlib.adler32(test_string, 2**8).should == 701435419
21
+ Zlib.adler32(test_string, 2**16).should == 63966491
22
+ lambda { Zlib.adler32(test_string, 2**128) }.should raise_error(RangeError)
23
+ end
24
+
25
+ it "calculates the Adler checksum for string and initial Adler value for Bignums" do
26
+ test_string = "This is a test string! How exciting!%?"
27
+ Zlib.adler32(test_string, 2**30).should == 1137642779
28
+ end
29
+
30
+ it "assumes that the initial value is given to adler, if adler is omitted" do
31
+ orig_crc = Zlib.adler32
32
+ Zlib.adler32("").should == Zlib.adler32("", orig_crc)
33
+ Zlib.adler32(" ").should == Zlib.adler32(" ", orig_crc)
34
+ Zlib.adler32("123456789").should == Zlib.adler32("123456789", orig_crc)
35
+ Zlib.adler32("!@#\{$\}%^&**()").should == Zlib.adler32("!@#\{$\}%^&**()", orig_crc)
36
+ Zlib.adler32("to be or not to be" * 22).should == Zlib.adler32("to be or not to be" * 22, orig_crc)
37
+ Zlib.adler32("0").should == Zlib.adler32("0", orig_crc)
38
+ Zlib.adler32((2**32).to_s).should == Zlib.adler32((2**32).to_s, orig_crc)
39
+ Zlib.adler32((2**64).to_s).should == Zlib.adler32((2**64).to_s, orig_crc)
40
+ end
41
+
42
+ it "it returns the CRC initial value, if string is omitted" do
43
+ Zlib.adler32.should == 1
44
+ end
45
+
46
+ end
@@ -0,0 +1,52 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+
4
+ describe "Zlib.crc32" do
5
+ it "calculates CRC checksum for string" do
6
+ Zlib.crc32("").should == 0
7
+ Zlib.crc32(" ").should == 3916222277
8
+ Zlib.crc32("123456789").should == 3421780262
9
+ Zlib.crc32("!@#\{$\}%^&**()").should == 2824518887
10
+ Zlib.crc32("to be or not to be" * 22).should == 1832379978
11
+ Zlib.crc32("0").should == 4108050209
12
+ Zlib.crc32((2**32).to_s).should == 3267533297
13
+ Zlib.crc32((2**64).to_s).should == 653721760
14
+ end
15
+
16
+ it "calculates CRC checksum for string and initial CRC value" do
17
+ test_string = "This is a test string! How exciting!%?"
18
+ # Zlib.crc32(test_string, -2**28).should == 3230195786
19
+ # Zlib.crc32(test_string, -2**20).should == 2770207303
20
+ # Zlib.crc32(test_string, -2**16).should == 2299432960
21
+ # Zlib.crc32(test_string, -2**8).should == 861809849
22
+ # Zlib.crc32(test_string, -1).should == 2170124077
23
+ Zlib.crc32(test_string, 0).should == 3864990561
24
+ Zlib.crc32(test_string, 1).should == 1809313411
25
+ Zlib.crc32(test_string, 2**8).should == 1722745982
26
+ Zlib.crc32(test_string, 2**16).should == 1932511220
27
+ lambda { Zlib.crc32(test_string, 2**128) }.should raise_error(RangeError)
28
+ end
29
+
30
+ it "calculates the CRC checksum for string and initial CRC value for Bignums" do
31
+ test_string = "This is a test string! How exciting!%?"
32
+ # Zlib.crc32(test_string, -2**30).should == 277228695
33
+ Zlib.crc32(test_string, 2**30).should == 46597132
34
+ end
35
+
36
+ it "assumes that the initial value is given to crc, if crc is omitted" do
37
+ orig_crc = Zlib.crc32
38
+ Zlib.crc32("").should == Zlib.crc32("", orig_crc)
39
+ Zlib.crc32(" ").should == Zlib.crc32(" ", orig_crc)
40
+ Zlib.crc32("123456789").should == Zlib.crc32("123456789", orig_crc)
41
+ Zlib.crc32("!@#\{$\}%^&**()").should == Zlib.crc32("!@#\{$\}%^&**()", orig_crc)
42
+ Zlib.crc32("to be or not to be" * 22).should == Zlib.crc32("to be or not to be" * 22, orig_crc)
43
+ Zlib.crc32("0").should == Zlib.crc32("0", orig_crc)
44
+ Zlib.crc32((2**32).to_s).should == Zlib.crc32((2**32).to_s, orig_crc)
45
+ Zlib.crc32((2**64).to_s).should == Zlib.crc32((2**64).to_s, orig_crc)
46
+ end
47
+
48
+ it "it returns the CRC initial value, if string is omitted" do
49
+ Zlib.crc32.should == 0
50
+ end
51
+
52
+ end
@@ -0,0 +1,11 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+
4
+ describe "Zlib.crc_table" do
5
+
6
+ it "should return the same value as zlib's get_crc_table()" do
7
+ Zlib.crc_table.should ==
8
+ [0, 1996959894, 3993919788, 2567524794, 124634137, 1886057615, 3915621685, 2657392035, 249268274, 2044508324, 3772115230, 2547177864, 162941995, 2125561021, 3887607047, 2428444049, 498536548, 1789927666, 4089016648, 2227061214, 450548861, 1843258603, 4107580753, 2211677639, 325883990, 1684777152, 4251122042, 2321926636, 335633487, 1661365465, 4195302755, 2366115317, 997073096, 1281953886, 3579855332, 2724688242, 1006888145, 1258607687, 3524101629, 2768942443, 901097722, 1119000684, 3686517206, 2898065728, 853044451, 1172266101, 3705015759, 2882616665, 651767980, 1373503546, 3369554304, 3218104598, 565507253, 1454621731, 3485111705, 3099436303, 671266974, 1594198024, 3322730930, 2970347812, 795835527, 1483230225, 3244367275, 3060149565, 1994146192, 31158534, 2563907772, 4023717930, 1907459465, 112637215, 2680153253, 3904427059, 2013776290, 251722036, 2517215374, 3775830040, 2137656763, 141376813, 2439277719, 3865271297, 1802195444, 476864866, 2238001368, 4066508878, 1812370925, 453092731, 2181625025, 4111451223, 1706088902, 314042704, 2344532202, 4240017532, 1658658271, 366619977, 2362670323, 4224994405, 1303535960, 984961486, 2747007092, 3569037538, 1256170817, 1037604311, 2765210733, 3554079995, 1131014506, 879679996, 2909243462, 3663771856, 1141124467, 855842277, 2852801631, 3708648649, 1342533948, 654459306, 3188396048, 3373015174, 1466479909, 544179635, 3110523913, 3462522015, 1591671054, 702138776, 2966460450, 3352799412, 1504918807, 783551873, 3082640443, 3233442989, 3988292384, 2596254646, 62317068, 1957810842, 3939845945, 2647816111, 81470997, 1943803523, 3814918930, 2489596804, 225274430, 2053790376, 3826175755, 2466906013, 167816743, 2097651377, 4027552580, 2265490386, 503444072, 1762050814, 4150417245, 2154129355, 426522225, 1852507879, 4275313526, 2312317920, 282753626, 1742555852, 4189708143, 2394877945, 397917763, 1622183637, 3604390888, 2714866558, 953729732, 1340076626, 3518719985, 2797360999, 1068828381, 1219638859, 3624741850, 2936675148, 906185462, 1090812512, 3747672003, 2825379669, 829329135, 1181335161, 3412177804, 3160834842, 628085408, 1382605366, 3423369109, 3138078467, 570562233, 1426400815, 3317316542, 2998733608, 733239954, 1555261956, 3268935591, 3050360625, 752459403, 1541320221, 2607071920, 3965973030, 1969922972, 40735498, 2617837225, 3943577151, 1913087877, 83908371, 2512341634, 3803740692, 2075208622, 213261112, 2463272603, 3855990285, 2094854071, 198958881, 2262029012, 4057260610, 1759359992, 534414190, 2176718541, 4139329115, 1873836001, 414664567, 2282248934, 4279200368, 1711684554, 285281116, 2405801727, 4167216745, 1634467795, 376229701, 2685067896, 3608007406, 1308918612, 956543938, 2808555105, 3495958263, 1231636301, 1047427035, 2932959818, 3654703836, 1088359270, 936918000, 2847714899, 3736837829, 1202900863, 817233897, 3183342108, 3401237130, 1404277552, 615818150, 3134207493, 3453421203, 1423857449, 601450431, 3009837614, 3294710456, 1567103746, 711928724, 3020668471, 3272380065, 1510334235, 755167117]
9
+ end
10
+
11
+ end
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,49 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+
4
+ describe 'Zlib::Deflate#deflate' do
5
+
6
+ before :each do
7
+ @deflator = Zlib::Deflate.new
8
+ end
9
+
10
+ it 'deflates some data' do
11
+ data = "\000" * 10
12
+
13
+ zipped = @deflator.deflate data, Zlib::FINISH
14
+ @deflator.finish
15
+
16
+ zipped.should == "x\234c`\200\001\000\000\n\000\001"
17
+ end
18
+
19
+ it 'deflates lots of data' do
20
+ data = "\000" * 32 * 1024
21
+
22
+ zipped = @deflator.deflate data, Zlib::FINISH
23
+ @deflator.finish
24
+
25
+ zipped.should == "x\234\355\301\001\001\000\000\000\200\220\376\257\356\b\n#{"\000" * 31}\030\200\000\000\001"
26
+ end
27
+
28
+ end
29
+
30
+ describe 'Zlib::Deflate::deflate' do
31
+
32
+ it 'deflates some data' do
33
+ data = "\000" * 10
34
+
35
+ zipped = Zlib::Deflate.deflate data
36
+
37
+ zipped.should == "x\234c`\200\001\000\000\n\000\001"
38
+ end
39
+
40
+ it 'deflates lots of data' do
41
+ data = "\000" * 32 * 1024
42
+
43
+ zipped = Zlib::Deflate.deflate data
44
+
45
+ zipped.should == "x\234\355\301\001\001\000\000\000\200\220\376\257\356\b\n#{"\000" * 31}\030\200\000\000\001"
46
+ end
47
+
48
+ end
49
+
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,21 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+
4
+ describe 'Zlib::Deflate#params' do
5
+ # ruby_bug '293', '1.9.0' do
6
+ it 'changes the deflate parameters' do
7
+ data = 'abcdefghijklm'
8
+
9
+ d = Zlib::Deflate.new Zlib::NO_COMPRESSION, Zlib::MAX_WBITS,
10
+ Zlib::DEF_MEM_LEVEL, Zlib::DEFAULT_STRATEGY
11
+
12
+ d << data.slice!(0..10)
13
+ d.params Zlib::BEST_COMPRESSION, Zlib::DEFAULT_STRATEGY
14
+ d << data
15
+
16
+ d.finish.should ==
17
+ "x\001\000\v\000\364\377abcdefghijk\002,'\027\000\#\364\005<"
18
+ # end
19
+ end
20
+ end
21
+
@@ -0,0 +1,14 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+
4
+ describe 'Zlib::Deflate#set_dictionary' do
5
+ it 'sets the dictionary' do
6
+ d = Zlib::Deflate.new
7
+ d.set_dictionary 'aaaaaaaaaa'
8
+ d << 'abcdefghij'
9
+
10
+ d.finish.should ==
11
+ "x\273\024\341\003\313KLJNIMK\317\310\314\002\000\025\206\003\370"
12
+ end
13
+ end
14
+
@@ -0,0 +1,23 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+ require 'stringio'
4
+
5
+
6
+ describe 'Zlib::GzipFile#close' do
7
+ it 'finishes the stream and closes the io' do
8
+ io = StringIO.new
9
+ Zlib::GzipWriter.wrap io do |gzio|
10
+ gzio.close
11
+
12
+ gzio.closed?.should == true
13
+
14
+ lambda { gzio.orig_name }.should \
15
+ raise_error(Zlib::GzipFile::Error, 'closed gzip stream')
16
+ lambda { gzio.comment }.should \
17
+ raise_error(Zlib::GzipFile::Error, 'closed gzip stream')
18
+ end
19
+
20
+ io.string[10..-1].should == "\003\000\000\000\000\000\000\000\000\000"
21
+ end
22
+ end
23
+
@@ -0,0 +1,18 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+ require 'stringio'
4
+
5
+
6
+ describe 'Zlib::GzipFile#closed?' do
7
+ it 'returns the closed status' do
8
+ io = StringIO.new
9
+ Zlib::GzipWriter.wrap io do |gzio|
10
+ gzio.closed?.should == false
11
+
12
+ gzio.close
13
+
14
+ gzio.closed?.should == true
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,28 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+ require 'stringio'
4
+
5
+
6
+ describe 'Zlib::GzipFile#comment' do
7
+ before :each do
8
+ @io = StringIO.new
9
+ end
10
+
11
+ it 'returns the name' do
12
+ Zlib::GzipWriter.wrap @io do |gzio|
13
+ gzio.comment = 'name'
14
+
15
+ gzio.comment.should == 'name'
16
+ end
17
+ end
18
+
19
+ it 'raises an error on a closed stream' do
20
+ Zlib::GzipWriter.wrap @io do |gzio|
21
+ gzio.close
22
+
23
+ lambda { gzio.comment }.should \
24
+ raise_error(Zlib::GzipFile::Error, 'closed gzip stream')
25
+ end
26
+ end
27
+ end
28
+
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,28 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+ require 'stringio'
4
+
5
+
6
+ describe 'Zlib::GzipFile#orig_name' do
7
+ before :each do
8
+ @io = StringIO.new
9
+ end
10
+
11
+ it 'returns the name' do
12
+ Zlib::GzipWriter.wrap @io do |gzio|
13
+ gzio.orig_name = 'name'
14
+
15
+ gzio.orig_name.should == 'name'
16
+ end
17
+ end
18
+
19
+ it 'raises an error on a closed stream' do
20
+ Zlib::GzipWriter.wrap @io do |gzio|
21
+ gzio.close
22
+
23
+ lambda { gzio.orig_name }.should \
24
+ raise_error(Zlib::GzipFile::Error, 'closed gzip stream')
25
+ end
26
+ end
27
+ end
28
+
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,23 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+ require 'stringio'
4
+
5
+
6
+ describe "GzipReader#eof?" do
7
+
8
+ before :each do
9
+ @data = '12345abcde'
10
+ @zip = "\037\213\b\000,\334\321G\000\00334261MLJNI\005\000\235\005\000$\n\000\000\000"
11
+ @io = StringIO.new @zip
12
+ end
13
+
14
+ it "returns true when at EOF" do
15
+ gz = Zlib::GzipReader.new @io
16
+
17
+ gz.eof?.should == false
18
+ gz.read
19
+ gz.eof?.should == true
20
+ end
21
+
22
+ end
23
+
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,27 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+ require 'stringio'
4
+
5
+
6
+ describe "GzipReader#pos" do
7
+
8
+ before :each do
9
+ @data = '12345abcde'
10
+ @zip = "\037\213\b\000,\334\321G\000\00334261MLJNI\005\000\235\005\000$\n\000\000\000"
11
+ @io = StringIO.new @zip
12
+ end
13
+
14
+ it "returns the position" do
15
+ gz = Zlib::GzipReader.new @io
16
+
17
+ gz.pos.should == 0
18
+
19
+ gz.read 5
20
+ gz.pos.should == 5
21
+
22
+ gz.read
23
+ gz.pos.should == @data.length
24
+ end
25
+
26
+ end
27
+