Sha256: 86a646abd15f662bedba533e726b01c3015c413872a55341eb3b7c0dfe3e85f3
Contents?: true
Size: 1.37 KB
Versions: 9
Compression:
Stored size: 1.37 KB
Contents
require_relative '../spec_helper' describe ZipTricks::SizeEstimator 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.estimate do | estimator | r = estimator.add_stored_entry(filename: "first-file.bin", size: raw_file_1.size) expect(r).to eq(estimator), "add_stored_entry should return self" estimator.add_stored_entry(filename: "second-file.bin", size: raw_file_2.size) r = estimator.add_compressed_entry(filename: "second-flie.bin", compressed_size: raw_file_3.size, uncompressed_size: raw_file_2.size, ) expect(r).to eq(estimator), "add_compressed_entry should return self" r = estimator.add_stored_entry(filename: "first-file-with-descriptor.bin", size: raw_file_1.size, use_data_descriptor: true) expect(r).to eq(estimator), "add_stored_entry should return self" r = estimator.add_compressed_entry(filename: "second-file-with-descriptor.bin", compressed_size: raw_file_3.size, uncompressed_size: raw_file_2.size, use_data_descriptor: true) expect(r).to eq(estimator), "add_compressed_entry should return self" end expect(predicted_size).to eq(2690095) end end
Version data entries
9 entries across 9 versions & 1 rubygems