mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:17:35 +00:00
Tests: Replace uses of JsonObject::get_deprecated()/get_ptr()
This commit is contained in:
parent
ad9b2043dd
commit
d55f763fcd
4 changed files with 18 additions and 16 deletions
|
@ -40,15 +40,17 @@ TEST_CASE(load_form)
|
||||||
|
|
||||||
EXPECT(form_json.is_object());
|
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_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) {
|
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();
|
auto result_object_or_error = parser.parse();
|
||||||
if (!result_object_or_error.is_error() && result_object_or_error.value().is_object()) {
|
if (!result_object_or_error.is_error() && result_object_or_error.value().is_object()) {
|
||||||
auto& result_object = result_object_or_error.value().as_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()) {
|
if (auto result_string = result_object.get_deprecated_string("result"sv); result_string.has_value()) {
|
||||||
auto const& view = result_string->as_string();
|
auto const& view = result_string.value();
|
||||||
// Timeout and assert fail already are the result of the stopping test
|
// Timeout and assert fail already are the result of the stopping test
|
||||||
if (view == "timeout"sv || view == "assert_fail"sv) {
|
if (view == "timeout"sv || view == "assert_fail"sv) {
|
||||||
failed = false;
|
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)) {
|
if (metadata.is_async && output.has("output"sv)) {
|
||||||
auto& output_messages = output.get_deprecated("output"sv);
|
auto output_messages = output.get_deprecated_string("output"sv);
|
||||||
VERIFY(output_messages.is_string());
|
VERIFY(output_messages.has_value());
|
||||||
if (output_messages.as_string().contains("AsyncTestFailure:InternalError: TODO("sv)) {
|
if (output_messages->contains("AsyncTestFailure:InternalError: TODO("sv)) {
|
||||||
output.set("todo_error", true);
|
output.set("todo_error", true);
|
||||||
output.set("result", "todo_error");
|
output.set("result", "todo_error");
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,13 +30,13 @@ TEST_SETUP
|
||||||
auto testcase = tests[i].as_object();
|
auto testcase = tests[i].as_object();
|
||||||
|
|
||||||
auto name = DeprecatedString::formatted("{}_ex{}_{}..{}",
|
auto name = DeprecatedString::formatted("{}_ex{}_{}..{}",
|
||||||
testcase.get_deprecated("section"sv),
|
testcase.get("section"sv).value(),
|
||||||
testcase.get_deprecated("example"sv),
|
testcase.get("example"sv).value(),
|
||||||
testcase.get_deprecated("start_line"sv),
|
testcase.get("start_line"sv).value(),
|
||||||
testcase.get_deprecated("end_line"sv));
|
testcase.get("end_line"sv).value());
|
||||||
|
|
||||||
DeprecatedString markdown = testcase.get_deprecated("markdown"sv).as_string();
|
DeprecatedString markdown = testcase.get_deprecated_string("markdown"sv).value();
|
||||||
DeprecatedString html = testcase.get_deprecated("html"sv).as_string();
|
DeprecatedString html = testcase.get_deprecated_string("html"sv).value();
|
||||||
|
|
||||||
Test::TestSuite::the().add_case(adopt_ref(*new Test::TestCase(
|
Test::TestSuite::the().add_case(adopt_ref(*new Test::TestCase(
|
||||||
name, [markdown, html]() {
|
name, [markdown, html]() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue