Reduced Unicode conversion code size (-122 bytes on AVR)

This commit is contained in:
Benoit Blanchon
2020-01-09 15:39:45 +01:00
parent 91b808381e
commit 5ec062cc71
5 changed files with 115 additions and 37 deletions

View File

@ -7,10 +7,9 @@
#include <catch.hpp>
TEST_CASE("Invalid JSON input") {
const char* testCases[] = {
"'\\u'", "'\\u000g'", "'\\u000'", "'\\u000G'", "'\\ud83d\\ud83d'",
"'\\udda4'", "'\\ud83d_'", "'\\u000/'", "\\x1234", "6a9",
"1,", "2]", "3}"};
const char* testCases[] = {"'\\u'", "'\\u000g'", "'\\u000'", "'\\u000G'",
"'\\u000/'", "\\x1234", "6a9", "1,",
"2]", "3}"};
const size_t testCount = sizeof(testCases) / sizeof(testCases[0]);
DynamicJsonDocument doc(4096);
@ -23,7 +22,14 @@ TEST_CASE("Invalid JSON input") {
}
TEST_CASE("Invalid JSON input that should pass") {
const char* testCases[] = {"nulL", "tru3", "fals3"};
const char* testCases[] = {
"nulL",
"tru3",
"fals3",
"'\\ud83d'", // leading surrogate without a trailing surrogate
"'\\udda4'", // trailing surrogate without a leading surrogate
"'\\ud83d\\ud83d'", // two leading surrogates
};
const size_t testCount = sizeof(testCases) / sizeof(testCases[0]);
DynamicJsonDocument doc(4096);