pr-zlib 1.0.1 → 1.0.2
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.
- checksums.yaml +4 -4
- data/CHANGES +13 -10
- data/MANIFEST +17 -17
- data/README +42 -42
- data/Rakefile +119 -119
- data/bin/minizip.rb +173 -173
- data/examples/example_rbzlib.rb +385 -385
- data/lib/pr/rbzlib.rb +5060 -5060
- data/lib/pr/zlib.rb +1554 -1550
- data/pr-zlib.gemspec +22 -22
- data/profile/bench_pr_zlib.rb +43 -43
- data/profile/bench_zlib.rb +43 -43
- data/profile/profile_pr_zlib_read.rb +28 -28
- data/profile/profile_pr_zlib_write.rb +26 -26
- data/test/test_zlib.rb +160 -160
- data/test/test_zlib_gzip_reader.rb +183 -183
- data/test/test_zlib_gzip_writer.rb +184 -184
- data/test/test_zlib_zstream.rb +146 -146
- metadata +3 -3
    
        data/pr-zlib.gemspec
    CHANGED
    
    | @@ -1,22 +1,22 @@ | |
| 1 | 
            -
            require 'rubygems'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            Gem::Specification.new do |spec|
         | 
| 4 | 
            -
              spec.name              = 'pr-zlib'
         | 
| 5 | 
            -
              spec.version           = '1.0. | 
| 6 | 
            -
              spec.authors           = ['Park Heesob', 'Daniel Berger']
         | 
| 7 | 
            -
              spec.email             = 'phasis@gmail.com'
         | 
| 8 | 
            -
              spec.homepage          = 'https://github.com/djberg96/pr-zlib'
         | 
| 9 | 
            -
              spec.summary           = 'Pure Ruby version of the zlib library'
         | 
| 10 | 
            -
              spec.test_files        = Dir['test/*.rb']
         | 
| 11 | 
            -
              spec.files             = Dir["**/*"].reject{ |f| f.include?('git') }
         | 
| 12 | 
            -
              spec.extra_rdoc_files  = ['README', 'CHANGES', 'MANIFEST']
         | 
| 13 | 
            -
               
         | 
| 14 | 
            -
              spec.add_development_dependency('test-unit', '>= 2.4.0')
         | 
| 15 | 
            -
              spec.add_development_dependency('ruby-prof')
         | 
| 16 | 
            -
               
         | 
| 17 | 
            -
              spec.description = <<-EOF
         | 
| 18 | 
            -
                The pr-zlib library is a pure Ruby implementation of both the zlib C
         | 
| 19 | 
            -
                library, and the Ruby zlib interface that ships as part of the standard
         | 
| 20 | 
            -
                library.
         | 
| 21 | 
            -
              EOF
         | 
| 22 | 
            -
            end
         | 
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Gem::Specification.new do |spec|
         | 
| 4 | 
            +
              spec.name              = 'pr-zlib'
         | 
| 5 | 
            +
              spec.version           = '1.0.2'
         | 
| 6 | 
            +
              spec.authors           = ['Park Heesob', 'Daniel Berger']
         | 
| 7 | 
            +
              spec.email             = 'phasis@gmail.com'
         | 
| 8 | 
            +
              spec.homepage          = 'https://github.com/djberg96/pr-zlib'
         | 
| 9 | 
            +
              spec.summary           = 'Pure Ruby version of the zlib library'
         | 
| 10 | 
            +
              spec.test_files        = Dir['test/*.rb']
         | 
| 11 | 
            +
              spec.files             = Dir["**/*"].reject{ |f| f.include?('git') }
         | 
| 12 | 
            +
              spec.extra_rdoc_files  = ['README', 'CHANGES', 'MANIFEST']
         | 
| 13 | 
            +
               
         | 
| 14 | 
            +
              spec.add_development_dependency('test-unit', '>= 2.4.0')
         | 
| 15 | 
            +
              spec.add_development_dependency('ruby-prof')
         | 
| 16 | 
            +
               
         | 
| 17 | 
            +
              spec.description = <<-EOF
         | 
| 18 | 
            +
                The pr-zlib library is a pure Ruby implementation of both the zlib C
         | 
| 19 | 
            +
                library, and the Ruby zlib interface that ships as part of the standard
         | 
| 20 | 
            +
                library.
         | 
| 21 | 
            +
              EOF
         | 
| 22 | 
            +
            end
         | 
    
        data/profile/bench_pr_zlib.rb
    CHANGED
    
    | @@ -1,43 +1,43 @@ | |
| 1 | 
            -
            ########################################################################
         | 
| 2 | 
            -
            # This benchmarks the zlib library that ships as part of the Ruby
         | 
| 3 | 
            -
            # standard library.
         | 
| 4 | 
            -
            #
         | 
| 5 | 
            -
            # You can run this benchmark via the bench:przlib Rake task.
         | 
| 6 | 
            -
            ########################################################################
         | 
| 7 | 
            -
            require 'pr/zlib'
         | 
| 8 | 
            -
            require 'benchmark'
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            print "\n\n== Running the benchmarks for pr-zlib ==\n\n"
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            # First, let's create a ~7 MB text file.
         | 
| 13 | 
            -
             | 
| 14 | 
            -
            FILE_NAME = "benchmark.txt"
         | 
| 15 | 
            -
            GZ_FILE_NAME = "benchmark.txt.gz"
         | 
| 16 | 
            -
             | 
| 17 | 
            -
            File.open(FILE_NAME, "w") do |fh|
         | 
| 18 | 
            -
              10000.times{ |x|
         | 
| 19 | 
            -
                s = "Now is the time for #{x} good men to come to the aid of their country."
         | 
| 20 | 
            -
                fh.puts s
         | 
| 21 | 
            -
              }
         | 
| 22 | 
            -
            end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
            Benchmark.bm do |x|
         | 
| 25 | 
            -
              x.report("write") do
         | 
| 26 | 
            -
                5.times{
         | 
| 27 | 
            -
                  Zlib::GzipWriter.open(GZ_FILE_NAME) do |gz|
         | 
| 28 | 
            -
                    gz.write(File.read(FILE_NAME))
         | 
| 29 | 
            -
                  end
         | 
| 30 | 
            -
                }
         | 
| 31 | 
            -
              end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
              x.report("read") do
         | 
| 34 | 
            -
                5.times{
         | 
| 35 | 
            -
                  Zlib::GzipReader.open(GZ_FILE_NAME) do |gz|
         | 
| 36 | 
            -
                    gz.read
         | 
| 37 | 
            -
                  end
         | 
| 38 | 
            -
                }
         | 
| 39 | 
            -
              end
         | 
| 40 | 
            -
            end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
            File.delete(FILE_NAME) if File.exists?(FILE_NAME)
         | 
| 43 | 
            -
            File.delete(GZ_FILE_NAME) if File.exists?(GZ_FILE_NAME)
         | 
| 1 | 
            +
            ########################################################################
         | 
| 2 | 
            +
            # This benchmarks the zlib library that ships as part of the Ruby
         | 
| 3 | 
            +
            # standard library.
         | 
| 4 | 
            +
            #
         | 
| 5 | 
            +
            # You can run this benchmark via the bench:przlib Rake task.
         | 
| 6 | 
            +
            ########################################################################
         | 
| 7 | 
            +
            require 'pr/zlib'
         | 
| 8 | 
            +
            require 'benchmark'
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            print "\n\n== Running the benchmarks for pr-zlib ==\n\n"
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            # First, let's create a ~7 MB text file.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            FILE_NAME = "benchmark.txt"
         | 
| 15 | 
            +
            GZ_FILE_NAME = "benchmark.txt.gz"
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            File.open(FILE_NAME, "w") do |fh|
         | 
| 18 | 
            +
              10000.times{ |x|
         | 
| 19 | 
            +
                s = "Now is the time for #{x} good men to come to the aid of their country."
         | 
| 20 | 
            +
                fh.puts s
         | 
| 21 | 
            +
              }
         | 
| 22 | 
            +
            end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            Benchmark.bm do |x|
         | 
| 25 | 
            +
              x.report("write") do
         | 
| 26 | 
            +
                5.times{
         | 
| 27 | 
            +
                  Zlib::GzipWriter.open(GZ_FILE_NAME) do |gz|
         | 
| 28 | 
            +
                    gz.write(File.read(FILE_NAME))
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
                }
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
              x.report("read") do
         | 
| 34 | 
            +
                5.times{
         | 
| 35 | 
            +
                  Zlib::GzipReader.open(GZ_FILE_NAME) do |gz|
         | 
| 36 | 
            +
                    gz.read
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
                }
         | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
            end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            File.delete(FILE_NAME) if File.exists?(FILE_NAME)
         | 
| 43 | 
            +
            File.delete(GZ_FILE_NAME) if File.exists?(GZ_FILE_NAME)
         | 
    
        data/profile/bench_zlib.rb
    CHANGED
    
    | @@ -1,43 +1,43 @@ | |
| 1 | 
            -
            ########################################################################
         | 
| 2 | 
            -
            # This benchmarks the zlib library that ships as part of the Ruby
         | 
| 3 | 
            -
            # standard library.
         | 
| 4 | 
            -
            #
         | 
| 5 | 
            -
            # You can run this benchmark via the bench-zlib Rake task.
         | 
| 6 | 
            -
            ########################################################################
         | 
| 7 | 
            -
            require 'zlib'
         | 
| 8 | 
            -
            require 'benchmark'
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            print "\n\n== Running the benchmarks for zlib (stdlib) ==\n\n"
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            # First, let's create a ~7 MB text file.
         | 
| 13 | 
            -
             | 
| 14 | 
            -
            FILE_NAME = "benchmark.txt"
         | 
| 15 | 
            -
            GZ_FILE_NAME = "benchmark.txt.gz"
         | 
| 16 | 
            -
             | 
| 17 | 
            -
            File.open(FILE_NAME, "w") do |fh|
         | 
| 18 | 
            -
              10000.times{ |x|
         | 
| 19 | 
            -
                s = "Now is the time for #{x} good men to come to the aid of their country."
         | 
| 20 | 
            -
                fh.puts s
         | 
| 21 | 
            -
              }
         | 
| 22 | 
            -
            end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
            Benchmark.bm do |x|
         | 
| 25 | 
            -
              x.report("write") do
         | 
| 26 | 
            -
                5.times{
         | 
| 27 | 
            -
                  Zlib::GzipWriter.open(GZ_FILE_NAME) do |gz|
         | 
| 28 | 
            -
                    gz.write(File.read(FILE_NAME))
         | 
| 29 | 
            -
                  end
         | 
| 30 | 
            -
                }
         | 
| 31 | 
            -
              end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
              x.report("read") do
         | 
| 34 | 
            -
                5.times{
         | 
| 35 | 
            -
                  Zlib::GzipReader.open(GZ_FILE_NAME) do |gz|
         | 
| 36 | 
            -
                    gz.read
         | 
| 37 | 
            -
                  end
         | 
| 38 | 
            -
                }
         | 
| 39 | 
            -
              end
         | 
| 40 | 
            -
            end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
            File.delete(FILE_NAME) if File.exists?(FILE_NAME)
         | 
| 43 | 
            -
            File.delete(GZ_FILE_NAME) if File.exists?(GZ_FILE_NAME)
         | 
| 1 | 
            +
            ########################################################################
         | 
| 2 | 
            +
            # This benchmarks the zlib library that ships as part of the Ruby
         | 
| 3 | 
            +
            # standard library.
         | 
| 4 | 
            +
            #
         | 
| 5 | 
            +
            # You can run this benchmark via the bench-zlib Rake task.
         | 
| 6 | 
            +
            ########################################################################
         | 
| 7 | 
            +
            require 'zlib'
         | 
| 8 | 
            +
            require 'benchmark'
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            print "\n\n== Running the benchmarks for zlib (stdlib) ==\n\n"
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            # First, let's create a ~7 MB text file.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            FILE_NAME = "benchmark.txt"
         | 
| 15 | 
            +
            GZ_FILE_NAME = "benchmark.txt.gz"
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            File.open(FILE_NAME, "w") do |fh|
         | 
| 18 | 
            +
              10000.times{ |x|
         | 
| 19 | 
            +
                s = "Now is the time for #{x} good men to come to the aid of their country."
         | 
| 20 | 
            +
                fh.puts s
         | 
| 21 | 
            +
              }
         | 
| 22 | 
            +
            end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            Benchmark.bm do |x|
         | 
| 25 | 
            +
              x.report("write") do
         | 
| 26 | 
            +
                5.times{
         | 
| 27 | 
            +
                  Zlib::GzipWriter.open(GZ_FILE_NAME) do |gz|
         | 
| 28 | 
            +
                    gz.write(File.read(FILE_NAME))
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
                }
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
              x.report("read") do
         | 
| 34 | 
            +
                5.times{
         | 
| 35 | 
            +
                  Zlib::GzipReader.open(GZ_FILE_NAME) do |gz|
         | 
| 36 | 
            +
                    gz.read
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
                }
         | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
            end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            File.delete(FILE_NAME) if File.exists?(FILE_NAME)
         | 
| 43 | 
            +
            File.delete(GZ_FILE_NAME) if File.exists?(GZ_FILE_NAME)
         | 
| @@ -1,28 +1,28 @@ | |
| 1 | 
            -
            require 'pr/zlib'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            FILE_NAME = 'zlib_temp.txt'
         | 
| 4 | 
            -
            GZ_FILE_NAME = 'zlib_temp.txt.gz'
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            # Create a text file to use first.
         | 
| 7 | 
            -
            File.open(FILE_NAME, "w") do |fh|
         | 
| 8 | 
            -
              1000.times{ |x|
         | 
| 9 | 
            -
                s = "Now is the time for #{x} good men to come to the aid of their country."
         | 
| 10 | 
            -
                fh.puts s
         | 
| 11 | 
            -
              }
         | 
| 12 | 
            -
            end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
            Zlib::GzipWriter.open(GZ_FILE_NAME){ |gz| gz.write(IO.read(FILE_NAME)) }
         | 
| 15 | 
            -
             | 
| 16 | 
            -
            require 'ruby-prof'
         | 
| 17 | 
            -
             | 
| 18 | 
            -
            result = RubyProf.profile do
         | 
| 19 | 
            -
              Zlib::GzipReader.open(GZ_FILE_NAME) do |gz|
         | 
| 20 | 
            -
                gz.read
         | 
| 21 | 
            -
              end
         | 
| 22 | 
            -
            end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
            File.delete(FILE_NAME) if File.exists?(FILE_NAME)
         | 
| 25 | 
            -
            File.delete(GZ_FILE_NAME) if File.exists?(GZ_FILE_NAME)
         | 
| 26 | 
            -
             | 
| 27 | 
            -
            printer = RubyProf::FlatPrinter.new(result)
         | 
| 28 | 
            -
            printer.print(STDOUT)
         | 
| 1 | 
            +
            require 'pr/zlib'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            FILE_NAME = 'zlib_temp.txt'
         | 
| 4 | 
            +
            GZ_FILE_NAME = 'zlib_temp.txt.gz'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # Create a text file to use first.
         | 
| 7 | 
            +
            File.open(FILE_NAME, "w") do |fh|
         | 
| 8 | 
            +
              1000.times{ |x|
         | 
| 9 | 
            +
                s = "Now is the time for #{x} good men to come to the aid of their country."
         | 
| 10 | 
            +
                fh.puts s
         | 
| 11 | 
            +
              }
         | 
| 12 | 
            +
            end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            Zlib::GzipWriter.open(GZ_FILE_NAME){ |gz| gz.write(IO.read(FILE_NAME)) }
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            require 'ruby-prof'
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            result = RubyProf.profile do
         | 
| 19 | 
            +
              Zlib::GzipReader.open(GZ_FILE_NAME) do |gz|
         | 
| 20 | 
            +
                gz.read
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            File.delete(FILE_NAME) if File.exists?(FILE_NAME)
         | 
| 25 | 
            +
            File.delete(GZ_FILE_NAME) if File.exists?(GZ_FILE_NAME)
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            printer = RubyProf::FlatPrinter.new(result)
         | 
| 28 | 
            +
            printer.print(STDOUT)
         | 
| @@ -1,26 +1,26 @@ | |
| 1 | 
            -
            require 'pr/zlib'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            FILE_NAME = 'zlib_temp.txt'
         | 
| 4 | 
            -
            GZ_FILE_NAME = 'zlib_temp.txt.gz'
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            # Create a text file to use first.
         | 
| 7 | 
            -
            File.open(FILE_NAME, "w") do |fh|
         | 
| 8 | 
            -
              1000.times{ |x|
         | 
| 9 | 
            -
                s = "Now is the time for #{x} good men to come to the aid of their country."
         | 
| 10 | 
            -
                fh.puts s
         | 
| 11 | 
            -
              }
         | 
| 12 | 
            -
            end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
            require 'ruby-prof'
         | 
| 15 | 
            -
             | 
| 16 | 
            -
            result = RubyProf.profile do
         | 
| 17 | 
            -
              Zlib::GzipWriter.open(GZ_FILE_NAME) do |gz|
         | 
| 18 | 
            -
                gz.write(File.read(FILE_NAME))
         | 
| 19 | 
            -
              end
         | 
| 20 | 
            -
            end
         | 
| 21 | 
            -
             | 
| 22 | 
            -
            File.delete(FILE_NAME) if File.exists?(FILE_NAME)
         | 
| 23 | 
            -
            File.delete(GZ_FILE_NAME) if File.exists?(GZ_FILE_NAME)
         | 
| 24 | 
            -
             | 
| 25 | 
            -
            printer = RubyProf::FlatPrinter.new(result)
         | 
| 26 | 
            -
            printer.print(STDOUT)
         | 
| 1 | 
            +
            require 'pr/zlib'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            FILE_NAME = 'zlib_temp.txt'
         | 
| 4 | 
            +
            GZ_FILE_NAME = 'zlib_temp.txt.gz'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # Create a text file to use first.
         | 
| 7 | 
            +
            File.open(FILE_NAME, "w") do |fh|
         | 
| 8 | 
            +
              1000.times{ |x|
         | 
| 9 | 
            +
                s = "Now is the time for #{x} good men to come to the aid of their country."
         | 
| 10 | 
            +
                fh.puts s
         | 
| 11 | 
            +
              }
         | 
| 12 | 
            +
            end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            require 'ruby-prof'
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            result = RubyProf.profile do
         | 
| 17 | 
            +
              Zlib::GzipWriter.open(GZ_FILE_NAME) do |gz|
         | 
| 18 | 
            +
                gz.write(File.read(FILE_NAME))
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            File.delete(FILE_NAME) if File.exists?(FILE_NAME)
         | 
| 23 | 
            +
            File.delete(GZ_FILE_NAME) if File.exists?(GZ_FILE_NAME)
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            printer = RubyProf::FlatPrinter.new(result)
         | 
| 26 | 
            +
            printer.print(STDOUT)
         | 
    
        data/test/test_zlib.rb
    CHANGED
    
    | @@ -1,160 +1,160 @@ | |
| 1 | 
            -
            ########################################################################
         | 
| 2 | 
            -
            # test_zlib.rb
         | 
| 3 | 
            -
            #
         | 
| 4 | 
            -
            # Test case for the Zlib module.
         | 
| 5 | 
            -
            ########################################################################
         | 
| 6 | 
            -
            require 'test-unit'
         | 
| 7 | 
            -
            require 'pr/zlib'
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            class TC_Zlib < Test::Unit::TestCase
         | 
| 10 | 
            -
               def self.startup
         | 
| 11 | 
            -
               end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
               def setup
         | 
| 14 | 
            -
                  @zstream_funcs = Zlib::ZStreamFuncs.new
         | 
| 15 | 
            -
               end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
               def test_ruby_zlib_version
         | 
| 18 | 
            -
                  assert_equal('0.6.0', Zlib::VERSION)
         | 
| 19 | 
            -
                  assert_equal('0.6.0', Zlib::RUBY_ZLIB_VERSION)
         | 
| 20 | 
            -
               end
         | 
| 21 | 
            -
             | 
| 22 | 
            -
               def test_zlib_version
         | 
| 23 | 
            -
                  assert_equal('1.2.3', Zlib::ZLIB_VERSION)
         | 
| 24 | 
            -
                  assert_equal('1.0. | 
| 25 | 
            -
               end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
               def test_zlib_included_constants
         | 
| 28 | 
            -
                  assert_not_nil(Zlib::BINARY)
         | 
| 29 | 
            -
                  assert_not_nil(Zlib::ASCII)
         | 
| 30 | 
            -
                  assert_not_nil(Zlib::UNKNOWN)
         | 
| 31 | 
            -
               end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
               def test_zlib_included_compression_constants
         | 
| 34 | 
            -
                  assert_not_nil(Zlib::NO_COMPRESSION)
         | 
| 35 | 
            -
                  assert_not_nil(Zlib::BEST_SPEED)
         | 
| 36 | 
            -
                  assert_not_nil(Zlib::BEST_COMPRESSION)
         | 
| 37 | 
            -
                  assert_not_nil(Zlib::DEFAULT_COMPRESSION)
         | 
| 38 | 
            -
               end
         | 
| 39 | 
            -
             | 
| 40 | 
            -
               def test_zlib_included_encoding_constants
         | 
| 41 | 
            -
                  assert_not_nil(Zlib::FILTERED)
         | 
| 42 | 
            -
                  assert_not_nil(Zlib::HUFFMAN_ONLY)
         | 
| 43 | 
            -
                  assert_not_nil(Zlib::DEFAULT_STRATEGY)
         | 
| 44 | 
            -
                  assert_not_nil(Zlib::MAX_WBITS)
         | 
| 45 | 
            -
                  assert_not_nil(Zlib::DEF_MEM_LEVEL)
         | 
| 46 | 
            -
                  assert_not_nil(Zlib::MAX_MEM_LEVEL)
         | 
| 47 | 
            -
                  assert_not_nil(Zlib::NO_FLUSH)
         | 
| 48 | 
            -
                  assert_not_nil(Zlib::SYNC_FLUSH)
         | 
| 49 | 
            -
                  assert_not_nil(Zlib::FULL_FLUSH)
         | 
| 50 | 
            -
                  assert_not_nil(Zlib::FINISH)
         | 
| 51 | 
            -
               end
         | 
| 52 | 
            -
             | 
| 53 | 
            -
               def test_zlib_os_constants
         | 
| 54 | 
            -
                  assert_equal(0x00, Zlib::OS_MSDOS)
         | 
| 55 | 
            -
                  assert_equal(0x01, Zlib::OS_AMIGA)
         | 
| 56 | 
            -
                  assert_equal(0x02, Zlib::OS_VMS)
         | 
| 57 | 
            -
                  assert_equal(0x03, Zlib::OS_UNIX)
         | 
| 58 | 
            -
                  assert_equal(0x05, Zlib::OS_ATARI)
         | 
| 59 | 
            -
                  assert_equal(0x06, Zlib::OS_OS2)
         | 
| 60 | 
            -
                  assert_equal(0x07, Zlib::OS_MACOS)
         | 
| 61 | 
            -
                  assert_equal(0x0a, Zlib::OS_TOPS20)
         | 
| 62 | 
            -
                  assert_equal(0x0b, Zlib::OS_WIN32)
         | 
| 63 | 
            -
               end
         | 
| 64 | 
            -
             | 
| 65 | 
            -
               def test_zlib_zstream_flag_constants
         | 
| 66 | 
            -
                  assert_equal(0x1, Zlib::ZSTREAM_FLAG_READY)
         | 
| 67 | 
            -
                  assert_equal(0x2, Zlib::ZSTREAM_FLAG_IN_STREAM)
         | 
| 68 | 
            -
                  assert_equal(0x4, Zlib::ZSTREAM_FLAG_FINISHED)
         | 
| 69 | 
            -
                  assert_equal(0x8, Zlib::ZSTREAM_FLAG_CLOSING)
         | 
| 70 | 
            -
                  assert_equal(0x10, Zlib::ZSTREAM_FLAG_UNUSED)
         | 
| 71 | 
            -
               end
         | 
| 72 | 
            -
             | 
| 73 | 
            -
               def test_zlib_zstream_buffer_constants
         | 
| 74 | 
            -
                  assert_equal(1024, Zlib::ZSTREAM_INITIAL_BUFSIZE)
         | 
| 75 | 
            -
                  assert_equal(16384, Zlib::ZSTREAM_AVAIL_OUT_STEP_MAX)
         | 
| 76 | 
            -
                  assert_equal(2048, Zlib::ZSTREAM_AVAIL_OUT_STEP_MIN)
         | 
| 77 | 
            -
               end
         | 
| 78 | 
            -
             | 
| 79 | 
            -
               def test_zlib_version_module_function
         | 
| 80 | 
            -
                  assert_respond_to(Zlib, :zlib_version)
         | 
| 81 | 
            -
               end
         | 
| 82 | 
            -
             | 
| 83 | 
            -
               def test_adler32_module_function_basic
         | 
| 84 | 
            -
                  assert_respond_to(Zlib, :adler32)
         | 
| 85 | 
            -
                  assert_nothing_raised{ Zlib.adler32 }
         | 
| 86 | 
            -
               end
         | 
| 87 | 
            -
             | 
| 88 | 
            -
               def test_adler32_module_function
         | 
| 89 | 
            -
                  assert_equal(1, Zlib.adler32)
         | 
| 90 | 
            -
                  assert_equal(73204161, Zlib.adler32('test'))
         | 
| 91 | 
            -
                  assert_equal(1, Zlib.adler32(nil, 3))
         | 
| 92 | 
            -
                  assert_equal(73728451, Zlib.adler32('test', 3))
         | 
| 93 | 
            -
               end
         | 
| 94 | 
            -
             | 
| 95 | 
            -
               def test_crc32_module_function_basic
         | 
| 96 | 
            -
                  assert_respond_to(Zlib, :crc32)
         | 
| 97 | 
            -
                  assert_nothing_raised{ Zlib.crc32 }
         | 
| 98 | 
            -
               end
         | 
| 99 | 
            -
             | 
| 100 | 
            -
               def test_crc32_module_function
         | 
| 101 | 
            -
                  assert_equal(0, Zlib.crc32)
         | 
| 102 | 
            -
                  assert_equal(3632233996, Zlib.crc32('test'))
         | 
| 103 | 
            -
                  assert_equal(0, Zlib.crc32(nil, 3))
         | 
| 104 | 
            -
                  assert_equal(3402289634, Zlib.crc32('test', 3))
         | 
| 105 | 
            -
               end
         | 
| 106 | 
            -
             | 
| 107 | 
            -
               def test_crc_table_module_function_basic
         | 
| 108 | 
            -
                  assert_respond_to(Zlib, :crc_table)
         | 
| 109 | 
            -
                  assert_nothing_raised{ Zlib.crc_table }
         | 
| 110 | 
            -
                  assert_kind_of(Array, Zlib.crc_table)
         | 
| 111 | 
            -
               end
         | 
| 112 | 
            -
             | 
| 113 | 
            -
               def test_zstream_funcs_struct
         | 
| 114 | 
            -
                  assert_kind_of(Zlib::ZStreamFuncs, @zstream_funcs)
         | 
| 115 | 
            -
                  assert_respond_to(@zstream_funcs, :reset)
         | 
| 116 | 
            -
                  assert_respond_to(@zstream_funcs, :end)
         | 
| 117 | 
            -
                  assert_respond_to(@zstream_funcs, :run)
         | 
| 118 | 
            -
               end
         | 
| 119 | 
            -
             | 
| 120 | 
            -
               def test_error_class
         | 
| 121 | 
            -
                  assert_not_nil(Zlib::Error)
         | 
| 122 | 
            -
                  assert_kind_of(StandardError, Zlib::Error.new)
         | 
| 123 | 
            -
               end
         | 
| 124 | 
            -
             | 
| 125 | 
            -
               def test_stream_end_class
         | 
| 126 | 
            -
                  assert_not_nil(Zlib::StreamEnd)
         | 
| 127 | 
            -
                  assert_kind_of(Zlib::Error, Zlib::StreamEnd.new)
         | 
| 128 | 
            -
               end
         | 
| 129 | 
            -
             | 
| 130 | 
            -
               def test_need_dict_class
         | 
| 131 | 
            -
                  assert_kind_of(Zlib::Error, Zlib::NeedDict.new)
         | 
| 132 | 
            -
               end
         | 
| 133 | 
            -
             | 
| 134 | 
            -
               def test_data_error_class
         | 
| 135 | 
            -
                  assert_kind_of(Zlib::Error, Zlib::DataError.new)
         | 
| 136 | 
            -
               end
         | 
| 137 | 
            -
             | 
| 138 | 
            -
               def test_stream_error_class
         | 
| 139 | 
            -
                  assert_kind_of(Zlib::Error, Zlib::StreamError.new)
         | 
| 140 | 
            -
               end
         | 
| 141 | 
            -
             | 
| 142 | 
            -
               def test_mem_error_class
         | 
| 143 | 
            -
                  assert_kind_of(Zlib::Error, Zlib::MemError.new)
         | 
| 144 | 
            -
               end
         | 
| 145 | 
            -
             | 
| 146 | 
            -
               def test_buf_error_class
         | 
| 147 | 
            -
                  assert_kind_of(Zlib::Error, Zlib::BufError.new)
         | 
| 148 | 
            -
               end
         | 
| 149 | 
            -
             | 
| 150 | 
            -
               def test_version_error_class
         | 
| 151 | 
            -
                  assert_kind_of(Zlib::Error, Zlib::VersionError.new)
         | 
| 152 | 
            -
               end
         | 
| 153 | 
            -
             | 
| 154 | 
            -
               def teardown
         | 
| 155 | 
            -
                  @zstream_funcs = nil
         | 
| 156 | 
            -
               end
         | 
| 157 | 
            -
             | 
| 158 | 
            -
               def self.shutdown
         | 
| 159 | 
            -
               end
         | 
| 160 | 
            -
            end
         | 
| 1 | 
            +
            ########################################################################
         | 
| 2 | 
            +
            # test_zlib.rb
         | 
| 3 | 
            +
            #
         | 
| 4 | 
            +
            # Test case for the Zlib module.
         | 
| 5 | 
            +
            ########################################################################
         | 
| 6 | 
            +
            require 'test-unit'
         | 
| 7 | 
            +
            require 'pr/zlib'
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            class TC_Zlib < Test::Unit::TestCase
         | 
| 10 | 
            +
               def self.startup
         | 
| 11 | 
            +
               end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
               def setup
         | 
| 14 | 
            +
                  @zstream_funcs = Zlib::ZStreamFuncs.new
         | 
| 15 | 
            +
               end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
               def test_ruby_zlib_version
         | 
| 18 | 
            +
                  assert_equal('0.6.0', Zlib::VERSION)
         | 
| 19 | 
            +
                  assert_equal('0.6.0', Zlib::RUBY_ZLIB_VERSION)
         | 
| 20 | 
            +
               end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
               def test_zlib_version
         | 
| 23 | 
            +
                  assert_equal('1.2.3', Zlib::ZLIB_VERSION)
         | 
| 24 | 
            +
                  assert_equal('1.0.2', Zlib::PR_ZLIB_VERSION)
         | 
| 25 | 
            +
               end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
               def test_zlib_included_constants
         | 
| 28 | 
            +
                  assert_not_nil(Zlib::BINARY)
         | 
| 29 | 
            +
                  assert_not_nil(Zlib::ASCII)
         | 
| 30 | 
            +
                  assert_not_nil(Zlib::UNKNOWN)
         | 
| 31 | 
            +
               end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
               def test_zlib_included_compression_constants
         | 
| 34 | 
            +
                  assert_not_nil(Zlib::NO_COMPRESSION)
         | 
| 35 | 
            +
                  assert_not_nil(Zlib::BEST_SPEED)
         | 
| 36 | 
            +
                  assert_not_nil(Zlib::BEST_COMPRESSION)
         | 
| 37 | 
            +
                  assert_not_nil(Zlib::DEFAULT_COMPRESSION)
         | 
| 38 | 
            +
               end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
               def test_zlib_included_encoding_constants
         | 
| 41 | 
            +
                  assert_not_nil(Zlib::FILTERED)
         | 
| 42 | 
            +
                  assert_not_nil(Zlib::HUFFMAN_ONLY)
         | 
| 43 | 
            +
                  assert_not_nil(Zlib::DEFAULT_STRATEGY)
         | 
| 44 | 
            +
                  assert_not_nil(Zlib::MAX_WBITS)
         | 
| 45 | 
            +
                  assert_not_nil(Zlib::DEF_MEM_LEVEL)
         | 
| 46 | 
            +
                  assert_not_nil(Zlib::MAX_MEM_LEVEL)
         | 
| 47 | 
            +
                  assert_not_nil(Zlib::NO_FLUSH)
         | 
| 48 | 
            +
                  assert_not_nil(Zlib::SYNC_FLUSH)
         | 
| 49 | 
            +
                  assert_not_nil(Zlib::FULL_FLUSH)
         | 
| 50 | 
            +
                  assert_not_nil(Zlib::FINISH)
         | 
| 51 | 
            +
               end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
               def test_zlib_os_constants
         | 
| 54 | 
            +
                  assert_equal(0x00, Zlib::OS_MSDOS)
         | 
| 55 | 
            +
                  assert_equal(0x01, Zlib::OS_AMIGA)
         | 
| 56 | 
            +
                  assert_equal(0x02, Zlib::OS_VMS)
         | 
| 57 | 
            +
                  assert_equal(0x03, Zlib::OS_UNIX)
         | 
| 58 | 
            +
                  assert_equal(0x05, Zlib::OS_ATARI)
         | 
| 59 | 
            +
                  assert_equal(0x06, Zlib::OS_OS2)
         | 
| 60 | 
            +
                  assert_equal(0x07, Zlib::OS_MACOS)
         | 
| 61 | 
            +
                  assert_equal(0x0a, Zlib::OS_TOPS20)
         | 
| 62 | 
            +
                  assert_equal(0x0b, Zlib::OS_WIN32)
         | 
| 63 | 
            +
               end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
               def test_zlib_zstream_flag_constants
         | 
| 66 | 
            +
                  assert_equal(0x1, Zlib::ZSTREAM_FLAG_READY)
         | 
| 67 | 
            +
                  assert_equal(0x2, Zlib::ZSTREAM_FLAG_IN_STREAM)
         | 
| 68 | 
            +
                  assert_equal(0x4, Zlib::ZSTREAM_FLAG_FINISHED)
         | 
| 69 | 
            +
                  assert_equal(0x8, Zlib::ZSTREAM_FLAG_CLOSING)
         | 
| 70 | 
            +
                  assert_equal(0x10, Zlib::ZSTREAM_FLAG_UNUSED)
         | 
| 71 | 
            +
               end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
               def test_zlib_zstream_buffer_constants
         | 
| 74 | 
            +
                  assert_equal(1024, Zlib::ZSTREAM_INITIAL_BUFSIZE)
         | 
| 75 | 
            +
                  assert_equal(16384, Zlib::ZSTREAM_AVAIL_OUT_STEP_MAX)
         | 
| 76 | 
            +
                  assert_equal(2048, Zlib::ZSTREAM_AVAIL_OUT_STEP_MIN)
         | 
| 77 | 
            +
               end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
               def test_zlib_version_module_function
         | 
| 80 | 
            +
                  assert_respond_to(Zlib, :zlib_version)
         | 
| 81 | 
            +
               end
         | 
| 82 | 
            +
             | 
| 83 | 
            +
               def test_adler32_module_function_basic
         | 
| 84 | 
            +
                  assert_respond_to(Zlib, :adler32)
         | 
| 85 | 
            +
                  assert_nothing_raised{ Zlib.adler32 }
         | 
| 86 | 
            +
               end
         | 
| 87 | 
            +
             | 
| 88 | 
            +
               def test_adler32_module_function
         | 
| 89 | 
            +
                  assert_equal(1, Zlib.adler32)
         | 
| 90 | 
            +
                  assert_equal(73204161, Zlib.adler32('test'))
         | 
| 91 | 
            +
                  assert_equal(1, Zlib.adler32(nil, 3))
         | 
| 92 | 
            +
                  assert_equal(73728451, Zlib.adler32('test', 3))
         | 
| 93 | 
            +
               end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
               def test_crc32_module_function_basic
         | 
| 96 | 
            +
                  assert_respond_to(Zlib, :crc32)
         | 
| 97 | 
            +
                  assert_nothing_raised{ Zlib.crc32 }
         | 
| 98 | 
            +
               end
         | 
| 99 | 
            +
             | 
| 100 | 
            +
               def test_crc32_module_function
         | 
| 101 | 
            +
                  assert_equal(0, Zlib.crc32)
         | 
| 102 | 
            +
                  assert_equal(3632233996, Zlib.crc32('test'))
         | 
| 103 | 
            +
                  assert_equal(0, Zlib.crc32(nil, 3))
         | 
| 104 | 
            +
                  assert_equal(3402289634, Zlib.crc32('test', 3))
         | 
| 105 | 
            +
               end
         | 
| 106 | 
            +
             | 
| 107 | 
            +
               def test_crc_table_module_function_basic
         | 
| 108 | 
            +
                  assert_respond_to(Zlib, :crc_table)
         | 
| 109 | 
            +
                  assert_nothing_raised{ Zlib.crc_table }
         | 
| 110 | 
            +
                  assert_kind_of(Array, Zlib.crc_table)
         | 
| 111 | 
            +
               end
         | 
| 112 | 
            +
             | 
| 113 | 
            +
               def test_zstream_funcs_struct
         | 
| 114 | 
            +
                  assert_kind_of(Zlib::ZStreamFuncs, @zstream_funcs)
         | 
| 115 | 
            +
                  assert_respond_to(@zstream_funcs, :reset)
         | 
| 116 | 
            +
                  assert_respond_to(@zstream_funcs, :end)
         | 
| 117 | 
            +
                  assert_respond_to(@zstream_funcs, :run)
         | 
| 118 | 
            +
               end
         | 
| 119 | 
            +
             | 
| 120 | 
            +
               def test_error_class
         | 
| 121 | 
            +
                  assert_not_nil(Zlib::Error)
         | 
| 122 | 
            +
                  assert_kind_of(StandardError, Zlib::Error.new)
         | 
| 123 | 
            +
               end
         | 
| 124 | 
            +
             | 
| 125 | 
            +
               def test_stream_end_class
         | 
| 126 | 
            +
                  assert_not_nil(Zlib::StreamEnd)
         | 
| 127 | 
            +
                  assert_kind_of(Zlib::Error, Zlib::StreamEnd.new)
         | 
| 128 | 
            +
               end
         | 
| 129 | 
            +
             | 
| 130 | 
            +
               def test_need_dict_class
         | 
| 131 | 
            +
                  assert_kind_of(Zlib::Error, Zlib::NeedDict.new)
         | 
| 132 | 
            +
               end
         | 
| 133 | 
            +
             | 
| 134 | 
            +
               def test_data_error_class
         | 
| 135 | 
            +
                  assert_kind_of(Zlib::Error, Zlib::DataError.new)
         | 
| 136 | 
            +
               end
         | 
| 137 | 
            +
             | 
| 138 | 
            +
               def test_stream_error_class
         | 
| 139 | 
            +
                  assert_kind_of(Zlib::Error, Zlib::StreamError.new)
         | 
| 140 | 
            +
               end
         | 
| 141 | 
            +
             | 
| 142 | 
            +
               def test_mem_error_class
         | 
| 143 | 
            +
                  assert_kind_of(Zlib::Error, Zlib::MemError.new)
         | 
| 144 | 
            +
               end
         | 
| 145 | 
            +
             | 
| 146 | 
            +
               def test_buf_error_class
         | 
| 147 | 
            +
                  assert_kind_of(Zlib::Error, Zlib::BufError.new)
         | 
| 148 | 
            +
               end
         | 
| 149 | 
            +
             | 
| 150 | 
            +
               def test_version_error_class
         | 
| 151 | 
            +
                  assert_kind_of(Zlib::Error, Zlib::VersionError.new)
         | 
| 152 | 
            +
               end
         | 
| 153 | 
            +
             | 
| 154 | 
            +
               def teardown
         | 
| 155 | 
            +
                  @zstream_funcs = nil
         | 
| 156 | 
            +
               end
         | 
| 157 | 
            +
             | 
| 158 | 
            +
               def self.shutdown
         | 
| 159 | 
            +
               end
         | 
| 160 | 
            +
            end
         |