Sha256: 4f562c0fc48033f3040d2bc43b502798a3aa3cbf419e4a55e231594cc0f3a1f2

Contents?: true

Size: 853 Bytes

Versions: 2

Compression:

Stored size: 853 Bytes

Contents

require_relative '../spec_helper'

describe ZipTricks::StoredSizeEstimator do
  it 'accurately predicts the output zip size' do
    # Generate a couple of random files
    raw_file_1 = SecureRandom.random_bytes(1024 * 20)
    raw_file_2 = SecureRandom.random_bytes(1024 * 128)
    raw_file_3 = SecureRandom.random_bytes(1258695)

    predicted_size = described_class.perform_fake_archiving do | estimator |
      r = estimator.add_stored_entry("first-file.bin", raw_file_1.size)
      expect(r).to eq(estimator), "add_stored_entry should return self"

      estimator.add_stored_entry("second-file.bin", raw_file_2.size)

      r = estimator.add_compressed_entry("second-flie.bin", raw_file_2.size, raw_file_3.size)
      expect(r).to eq(estimator), "add_compressed_entry should return self"
    end

    expect(predicted_size).to eq(1410585)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zip_tricks-2.8.1 spec/zip_tricks/stored_size_estimator_spec.rb
zip_tricks-2.8.0 spec/zip_tricks/stored_size_estimator_spec.rb