diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-15 01:46:51 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-17 00:21:10 +0100 |
commit | 587f9af960daa9f003ec9e41751cdc4ce50b87dd (patch) | |
tree | 41bc5b51741dffcc23e3e4b63d4c17a37e2e03d7 /Tests/AK/TestJSON.cpp | |
parent | 304c03f457e294a3d756860325d93b809f50f7a6 (diff) | |
download | serenity-587f9af960daa9f003ec9e41751cdc4ce50b87dd.zip |
AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)
Also add slightly richer parse errors now that we can include a string
literal with returned errors.
This will allow us to use TRY() when working with JSON data.
Diffstat (limited to 'Tests/AK/TestJSON.cpp')
-rw-r--r-- | Tests/AK/TestJSON.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Tests/AK/TestJSON.cpp b/Tests/AK/TestJSON.cpp index 0bc42167b6..aa1f8139a9 100644 --- a/Tests/AK/TestJSON.cpp +++ b/Tests/AK/TestJSON.cpp @@ -86,7 +86,7 @@ FIXME: Parse JSON from a Utf8View TEST_CASE(json_utf8_multibyte) { auto json_or_error = JsonValue::from_string("\"ลก\""); - EXPECT_EQ(json_or_error.has_value(), true); + EXPECT_EQ(json_or_error.is_error(), false); auto& json = json_or_error.value(); EXPECT_EQ(json.type(), JsonValue::Type::String); @@ -119,6 +119,6 @@ TEST_CASE(json_u64_roundtrip) auto big_value = 0xffffffffffffffffull; auto json = JsonValue(big_value).to_string(); auto value = JsonValue::from_string(json); - EXPECT_EQ_FORCE(value.has_value(), true); - EXPECT_EQ(value->as_u64(), big_value); + EXPECT_EQ_FORCE(value.is_error(), false); + EXPECT_EQ(value.value().as_u64(), big_value); } |