Sha256: bb120e8b2ddecff55b70e565975e88fb94f59b82e6cf53107702e860649a9bf8

Contents?: true

Size: 1.68 KB

Versions: 21

Compression:

Stored size: 1.68 KB

Contents

if ENV['FULL_ZIP64_TEST']
  require 'minitest/autorun'
  require 'minitest/unit'
  require 'fileutils'
  require 'zip'

  # test zip64 support for real, by actually exceeding the 32-bit size/offset limits
  # this test does not, of course, run with the normal unit tests! ;)

  class Zip64FullTest < MiniTest::Test
    def teardown
      ::Zip.reset!
    end

    def prepare_test_file(test_filename)
      ::File.delete(test_filename) if ::File.exist?(test_filename)
      test_filename
    end

    def test_large_zip_file
      ::Zip.write_zip64_support = true
      first_text = 'starting out small'
      last_text = 'this tests files starting after 4GB in the archive'
      test_filename = prepare_test_file('huge.zip')
      ::Zip::OutputStream.open(test_filename) do |io|
        io.put_next_entry('first_file.txt')
        io.write(first_text)

        # write just over 4GB (stored, so the zip file exceeds 4GB)
        buf = 'blah' * 16_384
        io.put_next_entry('huge_file', nil, nil, ::Zip::Entry::STORED)
        65_537.times { io.write(buf) }

        io.put_next_entry('last_file.txt')
        io.write(last_text)
      end

      ::Zip::File.open(test_filename) do |zf|
        assert_equal %w[first_file.txt huge_file last_file.txt], zf.entries.map(&:name)
        assert_equal first_text, zf.read('first_file.txt')
        assert_equal last_text, zf.read('last_file.txt')
      end

      # note: if this fails, be sure you have UnZip version 6.0 or newer
      # as this is the first version to support zip64 extensions
      # but some OSes (*cough* OSX) still bundle a 5.xx release
      assert system("unzip -tqq #{test_filename}"), 'third-party zip validation failed'
    end
  end

end

Version data entries

21 entries across 17 versions & 3 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.3/test/zip64_full_test.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/rubyzip-1.3.0/test/zip64_full_test.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/test/zip64_full_test.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/test/zip64_full_test.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/test/zip64_full_test.rb
rubyzip-1.3.0 test/zip64_full_test.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.2/test/zip64_full_test.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/rubyzip-1.2.2/test/zip64_full_test.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/test/zip64_full_test.rb
rubyzip-1.2.4 test/zip64_full_test.rb
rubyzip-1.2.3 test/zip64_full_test.rb
tdiary-5.0.13 vendor/bundle/gems/rubyzip-1.2.2/test/zip64_full_test.rb
tdiary-5.0.12.1 vendor/bundle/gems/rubyzip-1.2.2/test/zip64_full_test.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/rubyzip-1.2.2/test/zip64_full_test.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.2/test/zip64_full_test.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/rubyzip-1.2.2/test/zip64_full_test.rb
tdiary-5.0.11 vendor/bundle/gems/rubyzip-1.2.2/test/zip64_full_test.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/rubyzip-1.2.2/test/zip64_full_test.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/rubyzip-1.2.2/test/zip64_full_test.rb
vagrant-unbundled-2.1.4.0 vendor/bundle/ruby/2.5.0/gems/rubyzip-1.2.2/test/zip64_full_test.rb