summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-08-10 13:59:08 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-10 14:48:45 +0200
commit62ea2c54376fdff4140e591eb9000051da38eef9 (patch)
treed6610850fa8f34051fa374b13f3acdd1245dcc65 /AK
parentf6490098874606d0088cb5a4e07fdf719ad30450 (diff)
downloadserenity-62ea2c54376fdff4140e591eb9000051da38eef9.zip
AK: Add test case for duplicate JsonObject keys
Diffstat (limited to 'AK')
-rw-r--r--AK/Tests/TestJSON.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/AK/Tests/TestJSON.cpp b/AK/Tests/TestJSON.cpp
index ba196e4cdb..90a4a58d21 100644
--- a/AK/Tests/TestJSON.cpp
+++ b/AK/Tests/TestJSON.cpp
@@ -106,7 +106,7 @@ TEST_CASE(json_string)
EXPECT_EQ(json.type(), JsonValue::Type::String);
EXPECT_EQ(json.as_string().is_null(), false);
EXPECT_EQ(json.as_string().length(), size_t { 1 });
- EXPECT_EQ(json.as_string() == "A", true);
+ EXPECT_EQ(json.as_string() == "A", true);
}
TEST_CASE(json_utf8_character)
@@ -115,7 +115,7 @@ TEST_CASE(json_utf8_character)
EXPECT_EQ(json.type(), JsonValue::Type::String);
EXPECT_EQ(json.as_string().is_null(), false);
EXPECT_EQ(json.as_string().length(), size_t { 1 });
- EXPECT_EQ(json.as_string() == "A", true);
+ EXPECT_EQ(json.as_string() == "A", true);
}
TEST_CASE(json_utf8_multibyte)
@@ -124,8 +124,8 @@ TEST_CASE(json_utf8_multibyte)
EXPECT_EQ(json.type(), JsonValue::Type::String);
EXPECT_EQ(json.as_string().is_null(), false);
EXPECT_EQ(json.as_string().length(), size_t { 2 });
- EXPECT_EQ(json.as_string() == "ลก", true);
- EXPECT_EQ(json.as_string() == "\xc5\xa1", true);
+ EXPECT_EQ(json.as_string() == "ลก", true);
+ EXPECT_EQ(json.as_string() == "\xc5\xa1", true);
}
TEST_CASE(json_64_bit_value)
@@ -136,4 +136,13 @@ TEST_CASE(json_64_bit_value)
EXPECT_EQ(big_json_value.as_u64(), big_json_value_copy.as_u64());
}
+TEST_CASE(json_duplicate_keys)
+{
+ JsonObject json;
+ json.set("test", "foo");
+ json.set("test", "bar");
+ json.set("test", "baz");
+ EXPECT_EQ(json.to_string(), "{\"test\":\"baz\"}");
+}
+
TEST_MAIN(JSON)