1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-22 15:21:52 +03:00

🔨 improved code coverage

This commit is contained in:
Niels Lohmann
2017-04-01 08:34:58 +02:00
parent c32d2e5b3c
commit 3a5cf9bd0a
2 changed files with 13 additions and 6 deletions

View File

@ -10965,6 +10965,9 @@ class basic_json
codepoint = codepoint1;
}
// result of the above calculation yields a proper codepoint
assert(0x00 <= codepoint and codepoint <= 0x10FFFF);
// translate code point to bytes
if (codepoint < 0x80)
{
@ -10984,7 +10987,7 @@ class basic_json
add(0x80 | ((codepoint >> 6) & 0x3F));
add(0x80 | (codepoint & 0x3F));
}
else if (codepoint <= 0x10ffff)
else
{
// 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
add(0xF0 | (codepoint >> 18));
@ -10992,11 +10995,6 @@ class basic_json
add(0x80 | ((codepoint >> 6) & 0x3F));
add(0x80 | (codepoint & 0x3F));
}
else
{
error_message = "invalid string: code points above U+10FFFF are invalid";
return token_type::parse_error;
}
break;
}