diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-07-15 03:31:08 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-15 01:47:35 +0200 |
commit | 5d170810dbae64fff46bd581668e4b0bcd92b6f4 (patch) | |
tree | ee02c35db5dfd17581fd8d2ff24080cf6349035f /Tests | |
parent | 2404ad689729902fd27fe37f8ecbab935a6394e5 (diff) | |
download | serenity-5d170810dbae64fff46bd581668e4b0bcd92b6f4.zip |
AK: Make JsonParser correctly parse unsigned values larger than u32
Prior to this, it'd try to stuff them into an i64, which could fail and
give us nothing.
Even though this is an extension we've made to JSON, the parser should
be able to correctly round-trip from whatever our serialiser has
generated.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/AK/TestJSON.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Tests/AK/TestJSON.cpp b/Tests/AK/TestJSON.cpp index 15f4e9ecad..86d4dce2ce 100644 --- a/Tests/AK/TestJSON.cpp +++ b/Tests/AK/TestJSON.cpp @@ -105,3 +105,12 @@ TEST_CASE(json_duplicate_keys) json.set("test", "baz"); EXPECT_EQ(json.to_string(), "{\"test\":\"baz\"}"); } + +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); +} |