From df8fd4e8c83b577ca84f0ac5ed1ce85e7d625a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20ASLIT=C3=9CRK?= Date: Sun, 14 Jun 2020 12:34:19 +0300 Subject: [PATCH] Test: Fix json parse test from unicode string --- AK/Tests/TestJSON.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/AK/Tests/TestJSON.cpp b/AK/Tests/TestJSON.cpp index 87dca328794..06a0fd0f621 100644 --- a/AK/Tests/TestJSON.cpp +++ b/AK/Tests/TestJSON.cpp @@ -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)