AK: Add test case for duplicate JsonObject keys

This commit is contained in:
Linus Groh 2020-08-10 13:59:08 +02:00 committed by Andreas Kling
parent f649009887
commit 62ea2c5437
Notes: sideshowbarker 2024-07-19 04:04:10 +09:00

View file

@ -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)