mirror of
https://github.com/nlohmann/json
synced 2024-11-27 14:20:07 +00:00
🔨 improved code coverage
This commit is contained in:
parent
c32d2e5b3c
commit
3a5cf9bd0a
10
src/json.hpp
10
src/json.hpp
@ -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;
|
||||
}
|
||||
|
@ -158,6 +158,15 @@ TEST_CASE("lexer class")
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("very large string")
|
||||
{
|
||||
// strings larger than 1024 bytes yield a resize of the lexer's yytext buffer
|
||||
std::string s("\"");
|
||||
s += std::string(2048, 'x');
|
||||
s += "\"";
|
||||
CHECK((json::lexer(s.c_str(), 2050).scan() == json::lexer::token_type::value_string));
|
||||
}
|
||||
|
||||
/* NOTE: to_unicode function has been removed
|
||||
SECTION("to_unicode")
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user