summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-03-10 12:27:24 +0000
committerTim Flynn <trflynn89@pm.me>2022-03-10 12:04:22 -0500
commit5833c5538901d1b1cb3fcbca0c0868468dc8929c (patch)
treec96dbe0fb973765590d17e40ed962eae81fa9f9b /Tests
parent10429e1043a022339de8b84743caadf2da537a37 (diff)
downloadserenity-5833c5538901d1b1cb3fcbca0c0868468dc8929c.zip
Tests: Port test-cpp-parser to Core::Stream
Diffstat (limited to 'Tests')
-rw-r--r--Tests/LibCpp/test-cpp-parser.cpp17
1 files changed, 8 insertions, 9 deletions
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 <AK/LexicalPath.h>
#include <LibCore/DirIterator.h>
-#include <LibCore/File.h>
+#include <LibCore/Stream.h>
#include <LibCpp/Parser.h>
#include <LibTest/TestCase.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <string.h>
#include <unistd.h>
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<const char*>(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)