Class: Zip64FullTest
- Inherits:
-
MiniTest::Test
- Object
- MiniTest::Test
- Zip64FullTest
- Defined in:
- lib/hotplate/gems/rubyzip-1.1.7/test/zip64_full_test.rb
Overview
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! ;)
Instance Method Summary collapse
Instance Method Details
#prepareTestFile(test_filename) ⇒ Object
15 16 17 18 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/zip64_full_test.rb', line 15 def prepareTestFile(test_filename) ::File.delete(test_filename) if ::File.exist?(test_filename) return test_filename end |
#teardown ⇒ Object
11 12 13 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/zip64_full_test.rb', line 11 def teardown ::Zip.reset! end |
#test_largeZipFile ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/zip64_full_test.rb', line 20 def test_largeZipFile ::Zip.write_zip64_support = true first_text = 'starting out small' last_text = 'this tests files starting after 4GB in the archive' test_filename = prepareTestFile('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' * 16384 io.put_next_entry('huge_file', nil, nil, ::Zip::Entry::STORED) 65537.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 -t #{test_filename}"), "third-party zip validation failed" end |