From 5833c5538901d1b1cb3fcbca0c0868468dc8929c Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Thu, 10 Mar 2022 12:27:24 +0000 Subject: Tests: Port test-cpp-parser to Core::Stream --- Tests/LibCpp/test-cpp-parser.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'Tests') diff --git a/Tests/LibCpp/test-cpp-parser.cpp b/Tests/LibCpp/test-cpp-parser.cpp index 157fd9233e..8bcbcaa62f 100644 --- a/Tests/LibCpp/test-cpp-parser.cpp +++ b/Tests/LibCpp/test-cpp-parser.cpp @@ -6,22 +6,21 @@ #include #include -#include +#include #include #include -#include -#include -#include #include constexpr char TESTS_ROOT_DIR[] = "/home/anon/cpp-tests/parser"; -static String read_all(const String& path) +static String read_all(String const& path) { - auto result = Core::File::open(path, Core::OpenMode::ReadOnly); - VERIFY(!result.is_error()); - auto content = result.value()->read_all(); - return { reinterpret_cast(content.data()), content.size() }; + auto file = MUST(Core::Stream::File::open(path, Core::Stream::OpenMode::Read)); + auto file_size = MUST(file->size()); + auto content = MUST(ByteBuffer::create_uninitialized(file_size)); + if (!file->read_or_error(content.bytes())) + VERIFY_NOT_REACHED(); + return String { content.bytes() }; } TEST_CASE(test_regression) -- cgit v1.2.3