1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:18:12 +00:00

Tests: Remove the 10KB file read test for AllocatingMemoryStream

When we move the test to AK (together with the actual stream
implementation), finding the input file to read from is going to become
significantly harder, since the test also runs outside of SerenityOS.

Since this was just a smoke test during early development (and we should
now have reasonable coverage with actual usages in the other parts of
the OS), let's just remove that test instead of trying to make input
file lookups work.
This commit is contained in:
Tim Schumacher 2023-01-26 12:12:38 +01:00 committed by Andrew Kaster
parent 22f0d04f43
commit 11550f582b

View file

@ -680,39 +680,3 @@ TEST_CASE(allocating_memory_stream_offset_of_oob)
EXPECT(!offset.has_value());
}
}
TEST_CASE(allocating_memory_stream_10kb)
{
auto file = MUST(Core::Stream::File::open("/usr/Tests/LibCore/10kb.txt"sv, Core::Stream::OpenMode::Read));
size_t const file_size = MUST(file->size());
size_t constexpr test_chunk_size = 4096;
// Read file contents into the memory stream.
Core::Stream::AllocatingMemoryStream stream;
while (!file->is_eof()) {
Array<u8, test_chunk_size> array;
MUST(stream.write(MUST(file->read(array))));
}
EXPECT_EQ(stream.used_buffer_size(), file_size);
MUST(file->seek(0, SeekMode::SetPosition));
// Check the stream contents when reading back.
size_t offset = 0;
while (!file->is_eof()) {
Array<u8, test_chunk_size> file_array;
Array<u8, test_chunk_size> stream_array;
auto file_span = MUST(file->read(file_array));
auto stream_span = MUST(stream.read(stream_array));
EXPECT_EQ(file_span.size(), stream_span.size());
for (size_t i = 0; i < file_span.size(); i++) {
if (file_array[i] == stream_array[i])
continue;
FAIL(String::formatted("Data started to diverge at index {}: file={}, stream={}", offset + i, file_array[i], stream_array[i]));
}
offset += file_span.size();
}
}