mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:17:44 +00:00
AK+Everywhere: Change AK::fill_with_random to accept a Bytes object
Rather than the very C-like API we currently have, accepting a void* and a length, let's take a Bytes object instead. In almost all existing cases, the compiler figures out the length.
This commit is contained in:
parent
5c045b6934
commit
15532df83d
20 changed files with 37 additions and 39 deletions
|
@ -115,7 +115,7 @@ TEST_CASE(deflate_decompress_zeroes)
|
|||
TEST_CASE(deflate_round_trip_store)
|
||||
{
|
||||
auto original = ByteBuffer::create_uninitialized(1024).release_value();
|
||||
fill_with_random(original.data(), 1024);
|
||||
fill_with_random(original);
|
||||
auto compressed = Compress::DeflateCompressor::compress_all(original, Compress::DeflateCompressor::CompressionLevel::STORE);
|
||||
EXPECT(!compressed.is_error());
|
||||
auto uncompressed = Compress::DeflateDecompressor::decompress_all(compressed.value());
|
||||
|
@ -126,7 +126,7 @@ TEST_CASE(deflate_round_trip_store)
|
|||
TEST_CASE(deflate_round_trip_compress)
|
||||
{
|
||||
auto original = ByteBuffer::create_zeroed(2048).release_value();
|
||||
fill_with_random(original.data(), 1024); // we pre-filled the second half with 0s to make sure we test back references as well
|
||||
fill_with_random(original.bytes().trim(1024)); // we pre-filled the second half with 0s to make sure we test back references as well
|
||||
// Since the different levels just change how much time is spent looking for better matches, just use fast here to reduce test time
|
||||
auto compressed = Compress::DeflateCompressor::compress_all(original, Compress::DeflateCompressor::CompressionLevel::FAST);
|
||||
EXPECT(!compressed.is_error());
|
||||
|
@ -139,7 +139,7 @@ TEST_CASE(deflate_round_trip_compress_large)
|
|||
{
|
||||
auto size = Compress::DeflateCompressor::block_size * 2;
|
||||
auto original = ByteBuffer::create_uninitialized(size).release_value(); // Compress a buffer larger than the maximum block size to test the sliding window mechanism
|
||||
fill_with_random(original.data(), size);
|
||||
fill_with_random(original);
|
||||
// Since the different levels just change how much time is spent looking for better matches, just use fast here to reduce test time
|
||||
auto compressed = Compress::DeflateCompressor::compress_all(original, Compress::DeflateCompressor::CompressionLevel::FAST);
|
||||
EXPECT(!compressed.is_error());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue