Improved decoding of UTF-16 surrogate pairs (closes #1157)

This commit is contained in:
Kay Sievers
2020-01-02 13:14:02 +01:00
committed by Benoit Blanchon
parent 8550418875
commit 91b808381e
5 changed files with 36 additions and 13 deletions

View File

@ -7,9 +7,10 @@
#include <catch.hpp>
TEST_CASE("Invalid JSON input") {
const char* testCases[] = {"'\\u'", "'\\u000g'", "'\\u000'", "'\\u000G'",
"'\\u000/'", "\\x1234", "6a9", "1,",
"2]", "3}"};
const char* testCases[] = {
"'\\u'", "'\\u000g'", "'\\u000'", "'\\u000G'", "'\\ud83d\\ud83d'",
"'\\udda4'", "'\\ud83d_'", "'\\u000/'", "\\x1234", "6a9",
"1,", "2]", "3}"};
const size_t testCount = sizeof(testCases) / sizeof(testCases[0]);
DynamicJsonDocument doc(4096);

View File

@ -17,10 +17,10 @@ TEST_CASE("Valid JSON strings value") {
{"\'hello world\'", "hello world"},
{"\"1\\\"2\\\\3\\/4\\b5\\f6\\n7\\r8\\t9\"", "1\"2\\3/4\b5\f6\n7\r8\t9"},
{"'\\u0041'", "A"},
{"'\\u00e4'", "\xc3\xa4"}, // ä
{"'\\u00E4'", "\xc3\xa4"}, // ä
{"'\\u3042'", "\xe3\x81\x82"}, // あ
{"'\\u00e4'", "\xc3\xa4"}, // ä
{"'\\u00E4'", "\xc3\xa4"}, // ä
{"'\\u3042'", "\xe3\x81\x82"}, // あ
{"'\\ud83d\\udda4'", "\xf0\x9f\x96\xa4"}, // 🖤
};
const size_t testCount = sizeof(testCases) / sizeof(testCases[0]);