mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
Tests: Replace uses of JsonObject::get_deprecated()/get_ptr()
This commit is contained in:
parent
ad9b2043dd
commit
d55f763fcd
Notes:
sideshowbarker
2024-07-17 06:40:21 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/d55f763fcd Pull-request: https://github.com/SerenityOS/serenity/pull/17081 Reviewed-by: https://github.com/trflynn89 ✅
4 changed files with 18 additions and 16 deletions
|
@ -40,15 +40,17 @@ TEST_CASE(load_form)
|
|||
|
||||
EXPECT(form_json.is_object());
|
||||
|
||||
auto name = form_json.as_object().get_deprecated("name"sv).to_deprecated_string();
|
||||
auto name = form_json.as_object().get_deprecated_string("name"sv);
|
||||
EXPECT(name.has_value());
|
||||
|
||||
EXPECT_EQ(name, "Form1");
|
||||
EXPECT_EQ(name.value(), "Form1");
|
||||
|
||||
auto widgets = form_json.as_object().get_deprecated("widgets"sv).as_array();
|
||||
auto widgets = form_json.as_object().get_array("widgets"sv);
|
||||
EXPECT(widgets.has_value());
|
||||
|
||||
widgets.for_each([&](JsonValue const& widget_value) {
|
||||
widgets->for_each([&](JsonValue const& widget_value) {
|
||||
auto& widget_object = widget_value.as_object();
|
||||
auto widget_class = widget_object.get_deprecated("class"sv).as_string();
|
||||
auto widget_class = widget_object.get_deprecated_string("class"sv).value();
|
||||
widget_object.for_each_member([&]([[maybe_unused]] auto& property_name, [[maybe_unused]] const JsonValue& property_value) {
|
||||
});
|
||||
});
|
||||
|
|
|
@ -269,8 +269,8 @@ static ErrorOr<HashMap<size_t, TestResult>> run_test_files(Span<DeprecatedString
|
|||
auto result_object_or_error = parser.parse();
|
||||
if (!result_object_or_error.is_error() && result_object_or_error.value().is_object()) {
|
||||
auto& result_object = result_object_or_error.value().as_object();
|
||||
if (auto result_string = result_object.get_ptr("result"sv); result_string && result_string->is_string()) {
|
||||
auto const& view = result_string->as_string();
|
||||
if (auto result_string = result_object.get_deprecated_string("result"sv); result_string.has_value()) {
|
||||
auto const& view = result_string.value();
|
||||
// Timeout and assert fail already are the result of the stopping test
|
||||
if (view == "timeout"sv || view == "assert_fail"sv) {
|
||||
failed = false;
|
||||
|
|
|
@ -432,9 +432,9 @@ static bool verify_test(Result<void, TestError>& result, TestMetadata const& met
|
|||
}
|
||||
|
||||
if (metadata.is_async && output.has("output"sv)) {
|
||||
auto& output_messages = output.get_deprecated("output"sv);
|
||||
VERIFY(output_messages.is_string());
|
||||
if (output_messages.as_string().contains("AsyncTestFailure:InternalError: TODO("sv)) {
|
||||
auto output_messages = output.get_deprecated_string("output"sv);
|
||||
VERIFY(output_messages.has_value());
|
||||
if (output_messages->contains("AsyncTestFailure:InternalError: TODO("sv)) {
|
||||
output.set("todo_error", true);
|
||||
output.set("result", "todo_error");
|
||||
}
|
||||
|
|
|
@ -30,13 +30,13 @@ TEST_SETUP
|
|||
auto testcase = tests[i].as_object();
|
||||
|
||||
auto name = DeprecatedString::formatted("{}_ex{}_{}..{}",
|
||||
testcase.get_deprecated("section"sv),
|
||||
testcase.get_deprecated("example"sv),
|
||||
testcase.get_deprecated("start_line"sv),
|
||||
testcase.get_deprecated("end_line"sv));
|
||||
testcase.get("section"sv).value(),
|
||||
testcase.get("example"sv).value(),
|
||||
testcase.get("start_line"sv).value(),
|
||||
testcase.get("end_line"sv).value());
|
||||
|
||||
DeprecatedString markdown = testcase.get_deprecated("markdown"sv).as_string();
|
||||
DeprecatedString html = testcase.get_deprecated("html"sv).as_string();
|
||||
DeprecatedString markdown = testcase.get_deprecated_string("markdown"sv).value();
|
||||
DeprecatedString html = testcase.get_deprecated_string("html"sv).value();
|
||||
|
||||
Test::TestSuite::the().add_case(adopt_ref(*new Test::TestCase(
|
||||
name, [markdown, html]() {
|
||||
|
|
Loading…
Reference in a new issue