|
@@ -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();
|
|
|
- }
|
|
|
-}
|