pr-zlib 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,58 @@
1
+ ########################################################################
2
+ # test_zlib_inflate.rb
3
+ #
4
+ # Test case for the Zlib::Inflate class.
5
+ ########################################################################
6
+ require 'rubygems'
7
+ gem 'test-unit'
8
+
9
+ require 'pr/zlib'
10
+ require 'test/unit'
11
+
12
+ class TC_Zlib_Inflate < Test::Unit::TestCase
13
+ def self.startup
14
+ end
15
+
16
+ def setup
17
+ @inflate = Zlib::Inflate.new
18
+ end
19
+
20
+ def test_inflate_run_singleton_basic
21
+ assert_respond_to(Zlib::Inflate, :inflate_run)
22
+ end
23
+
24
+ def test_inflate_singleton_basic
25
+ assert_respond_to(Zlib::Inflate, :inflate)
26
+ end
27
+
28
+ #def test_initialize_copy_basic
29
+ #assert_respond_to(@inflate, :initialize_copy)
30
+ #end
31
+
32
+ def test_inflate_basic
33
+ assert_respond_to(@inflate, :inflate)
34
+ end
35
+
36
+ def test_append_basic
37
+ assert_respond_to(@inflate, :<<)
38
+ end
39
+
40
+ def test_sync_basic
41
+ assert_respond_to(@inflate, :sync)
42
+ end
43
+
44
+ def test_is_sync_point_basic
45
+ assert_respond_to(@inflate, :sync_point?)
46
+ end
47
+
48
+ def test_set_dictionary_basic
49
+ assert_respond_to(@inflate, :set_dictionary)
50
+ end
51
+
52
+ def teardown
53
+ @inflate = nil
54
+ end
55
+
56
+ def self.shutdown
57
+ end
58
+ end
@@ -0,0 +1,149 @@
1
+ require 'rubygems'
2
+ gem 'test-unit'
3
+
4
+ require 'test/unit'
5
+ require 'pr/zlib'
6
+
7
+ class TC_Zlib_Zstream < Test::Unit::TestCase
8
+ def self.startup
9
+ end
10
+
11
+ def setup
12
+ @zstream = Zlib::ZStream.new
13
+ @zfunc = Zlib::ZStreamFuncs.new
14
+ @zstream.zstream_init(@zfunc)
15
+ @src = Array.new(128, 0.chr)
16
+ end
17
+
18
+ def test_flags
19
+ assert_respond_to(@zstream, :flags)
20
+ assert_respond_to(@zstream, :flags=)
21
+ end
22
+
23
+ def test_buf
24
+ assert_respond_to(@zstream, :buf)
25
+ assert_respond_to(@zstream, :buf=)
26
+ end
27
+
28
+ def test_input
29
+ assert_respond_to(@zstream, :input)
30
+ assert_respond_to(@zstream, :input=)
31
+ end
32
+
33
+ def test_stream
34
+ assert_respond_to(@zstream, :stream)
35
+ assert_respond_to(@zstream, :stream=)
36
+ end
37
+
38
+ def test_func
39
+ assert_respond_to(@zstream, :func)
40
+ assert_respond_to(@zstream, :func=)
41
+ end
42
+
43
+ def test_raise_zlib_error_basic
44
+ assert_respond_to(@zstream, :raise_zlib_error)
45
+ end
46
+
47
+ def test_raise_zlib_error_stream_end
48
+ assert_raise(Zlib::StreamEnd){ @zstream.raise_zlib_error(Z_STREAM_END, nil) }
49
+ assert_raise_message('stream end'){ @zstream.raise_zlib_error(Z_STREAM_END, nil) }
50
+ end
51
+
52
+ def test_raise_zlib_error_need_dict
53
+ assert_raise(Zlib::NeedDict){ @zstream.raise_zlib_error(Z_NEED_DICT, nil) }
54
+ assert_raise_message('need dictionary'){ @zstream.raise_zlib_error(Z_NEED_DICT, nil) }
55
+ end
56
+
57
+ def test_raise_zlib_error_stream_error
58
+ assert_raise(Zlib::StreamError){ @zstream.raise_zlib_error(Z_STREAM_ERROR, nil) }
59
+ assert_raise_message('stream error'){ @zstream.raise_zlib_error(Z_STREAM_ERROR, nil) }
60
+ end
61
+
62
+ def test_raise_zlib_error_data_error
63
+ assert_raise(Zlib::DataError){ @zstream.raise_zlib_error(Z_DATA_ERROR, nil) }
64
+ assert_raise_message('data error'){ @zstream.raise_zlib_error(Z_DATA_ERROR, nil) }
65
+ end
66
+
67
+ def test_raise_zlib_error_buf_error
68
+ assert_raise(Zlib::BufError){ @zstream.raise_zlib_error(Z_BUF_ERROR, nil) }
69
+ assert_raise_message('buffer error'){ @zstream.raise_zlib_error(Z_BUF_ERROR, nil) }
70
+ end
71
+
72
+ def test_raise_zlib_error_version_error
73
+ assert_raise(Zlib::VersionError){ @zstream.raise_zlib_error(Z_VERSION_ERROR, nil) }
74
+ assert_raise_message('incompatible version'){ @zstream.raise_zlib_error(Z_VERSION_ERROR, nil) }
75
+ end
76
+
77
+ def test_raise_zlib_error_mem_error
78
+ assert_raise(Zlib::MemError){ @zstream.raise_zlib_error(Z_MEM_ERROR, nil) }
79
+ assert_raise_message('insufficient memory'){ @zstream.raise_zlib_error(Z_MEM_ERROR, nil) }
80
+ end
81
+
82
+ def test_raise_zlib_error_errno
83
+ assert_raise(SystemCallError){ @zstream.raise_zlib_error(Z_ERRNO, nil) }
84
+ assert_raise_message('unknown error - file error'){ @zstream.raise_zlib_error(Z_ERRNO, nil) }
85
+ end
86
+
87
+ def test_raise_zlib_error_unknown
88
+ #notify('I think there might be a problem here - need to investigate')
89
+ assert_raise(Zlib::Error){ @zstream.raise_zlib_error(999, nil) }
90
+ assert_raise_message('unknown error - file error'){ @zstream.raise_zlib_error(Z_ERRNO, nil) }
91
+ end
92
+
93
+ def test_zstream_expand_buffer_basic
94
+ assert_respond_to(@zstream, :zstream_expand_buffer)
95
+ assert_nothing_raised{ @zstream.zstream_expand_buffer }
96
+ end
97
+
98
+ # @zstream.buf set after call
99
+ def test_zstream_expand_buffer
100
+ assert_nil(@zstream.buf)
101
+ assert_nil(@zstream.zstream_expand_buffer)
102
+ assert_kind_of(Bytef, @zstream.buf)
103
+ end
104
+
105
+ def test_zstream_expand_buffer_expected_errors
106
+ #notify("Modify zstream_expand_buffer method to explicitly handle a nil @stream")
107
+ assert_raise(ArgumentError){ @zstream.zstream_expand_buffer(1) }
108
+ end
109
+
110
+ def test_zstream_append_buffer_basic
111
+ assert_respond_to(@zstream, :zstream_append_buffer)
112
+ assert_nothing_raised{ @zstream.zstream_append_buffer(@src, @src.length) }
113
+ end
114
+
115
+ # @zstream.buf set after call
116
+ def test_zstream_append_buffer
117
+ assert_nil(@zstream.buf)
118
+ assert_nil(@zstream.zstream_append_buffer(@src, @src.length))
119
+ assert_kind_of(Bytef, @zstream.buf)
120
+ end
121
+
122
+ def test_zstream_append_buffer_expected_errors
123
+ assert_raise(ArgumentError){ @zstream.zstream_append_buffer }
124
+ end
125
+
126
+ def test_zstream_detach_buffer_basic
127
+ assert_respond_to(@zstream, :zstream_detach_buffer)
128
+ assert_nothing_raised{ @zstream.zstream_detach_buffer }
129
+ end
130
+
131
+ def test_zstream_detach_buffer
132
+ assert_kind_of(String, @zstream.zstream_detach_buffer)
133
+ assert_not_nil(@zstream.buf)
134
+ end
135
+
136
+ def test_zstream_shift_buffer_basic
137
+ @zstream.buf = Bytef.new(0.chr * Zlib::ZSTREAM_INITIAL_BUFSIZE)
138
+ assert_respond_to(@zstream, :zstream_shift_buffer)
139
+ assert_nothing_raised{ @zstream.zstream_shift_buffer(1) }
140
+ end
141
+
142
+ def teardown
143
+ @zstream = nil
144
+ @src = nil
145
+ end
146
+
147
+ def self.shutdown
148
+ end
149
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pr-zlib
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Park Heesob
8
+ - Daniel Berger
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-06-12 00:00:00 -06:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: test-unit
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 2.0.2
25
+ version:
26
+ description: " The pr-zlib library is a pure Ruby implementation of both the zlib C\n library, and the Ruby zlib interface that ships as part of the standard\n library.\n"
27
+ email: phasis@gmail.com
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - README
34
+ - CHANGES
35
+ - MANIFEST
36
+ files:
37
+ - bin/minizip.rb
38
+ - CHANGES
39
+ - examples/example_rbzlib.rb
40
+ - lib/pr/rbzlib.rb
41
+ - lib/pr/zlib.rb
42
+ - MANIFEST
43
+ - pr-zlib.gemspec
44
+ - Rakefile
45
+ - README
46
+ - test/test_rbzlib.rb
47
+ - test/test_rbzlib_bytef.rb
48
+ - test/test_rbzlib_posf.rb
49
+ - test/test_zlib.rb
50
+ - test/test_zlib_deflate.rb
51
+ - test/test_zlib_gzip_file.rb
52
+ - test/test_zlib_gzip_reader.rb
53
+ - test/test_zlib_gzip_writer.rb
54
+ - test/test_zlib_inflate.rb
55
+ - test/test_zlib_zstream.rb
56
+ has_rdoc: true
57
+ homepage: http://www.rubyforge.org/projects/pure
58
+ licenses: []
59
+
60
+ post_install_message:
61
+ rdoc_options: []
62
+
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: "0"
70
+ version:
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "0"
76
+ version:
77
+ requirements: []
78
+
79
+ rubyforge_project: pure
80
+ rubygems_version: 1.3.4
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: Pure Ruby version of the zlib library
84
+ test_files:
85
+ - test/test_rbzlib.rb
86
+ - test/test_rbzlib_bytef.rb
87
+ - test/test_rbzlib_posf.rb
88
+ - test/test_zlib.rb
89
+ - test/test_zlib_deflate.rb
90
+ - test/test_zlib_gzip_file.rb
91
+ - test/test_zlib_gzip_reader.rb
92
+ - test/test_zlib_gzip_writer.rb
93
+ - test/test_zlib_inflate.rb
94
+ - test/test_zlib_zstream.rb