Tests: Port TestCommonmark to Core::Stream
This passes the same number of tests that it did before this change: > Out of 652 tests, 273 passed and 379 failed.
This commit is contained in:
parent
7ff99c3972
commit
2b2ddee77c
Notes:
sideshowbarker
2024-07-17 17:37:09 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/2b2ddee77c Pull-request: https://github.com/SerenityOS/serenity/pull/12987 Reviewed-by: https://github.com/trflynn89
1 changed files with 11 additions and 8 deletions
|
@ -8,20 +8,23 @@
|
|||
#include <AK/JsonObject.h>
|
||||
#include <AK/JsonParser.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibMarkdown/Document.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
#include <LibTest/TestSuite.h>
|
||||
|
||||
TEST_SETUP
|
||||
{
|
||||
auto file = Core::File::construct("/home/anon/commonmark.spec.json");
|
||||
if (!file->open(Core::OpenMode::ReadOnly)) {
|
||||
file = Core::File::construct("./commonmark.spec.json");
|
||||
VERIFY(file->open(Core::OpenMode::ReadOnly));
|
||||
}
|
||||
|
||||
String test_data(file->read_all(), AK::ShouldChomp::NoChomp);
|
||||
auto file_or_error = Core::Stream::File::open("/home/anon/commonmark.spec.json", Core::Stream::OpenMode::Read);
|
||||
if (file_or_error.is_error())
|
||||
file_or_error = Core::Stream::File::open("./commonmark.spec.json", Core::Stream::OpenMode::Read);
|
||||
VERIFY(!file_or_error.is_error());
|
||||
auto file = file_or_error.release_value();
|
||||
auto file_size = MUST(file->size());
|
||||
auto content = MUST(ByteBuffer::create_uninitialized(file_size));
|
||||
if (!file->read_or_error(content.bytes()))
|
||||
VERIFY_NOT_REACHED();
|
||||
String test_data { content.bytes() };
|
||||
|
||||
auto tests = JsonParser(test_data).parse().value().as_array();
|
||||
for (size_t i = 0; i < tests.size(); ++i) {
|
||||
|
|
Loading…
Add table
Reference in a new issue