Test: Fix json parse test from unicode string

This commit is contained in:
Hüseyin ASLITÜRK 2020-06-14 12:34:19 +03:00 committed by Andreas Kling
parent 00edc89288
commit df8fd4e8c8
Notes: sideshowbarker 2024-07-19 05:37:18 +09:00

View File

@ -100,12 +100,22 @@ TEST_CASE(json_empty_string)
EXPECT_EQ(json.as_string().is_empty(), true);
}
TEST_CASE(json_utf8_character)
TEST_CASE(json_string)
{
auto json = JsonValue::from_string("\"\xc3\x84\"").value();
auto json = JsonValue::from_string("\"A\"").value();
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().length(), size_t { 1 });
EXPECT_EQ(json.as_string() == "A", true);
}
TEST_CASE(json_utf8_character)
{
auto json = JsonValue::from_string("\"\\u0041\"").value();
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);
}
TEST_MAIN(JSON)