update the solution and testcase for issue740/899
This commit is contained in:
parent
a62add807c
commit
8a63256267
@ -110,7 +110,7 @@ inline const RegEx& Value() {
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
inline const RegEx& ValueInFlow() {
|
inline const RegEx& ValueInFlow() {
|
||||||
static const RegEx e = RegEx(':') + (BlankOrBreak() | RegEx(",}", REGEX_OR));
|
static const RegEx e = RegEx(':') + (BlankOrBreak() | RegEx(",]}", REGEX_OR));
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
inline const RegEx& ValueInJSONFlow() {
|
inline const RegEx& ValueInJSONFlow() {
|
||||||
@ -164,7 +164,8 @@ inline const RegEx& EndScalar() {
|
|||||||
}
|
}
|
||||||
inline const RegEx& EndScalarInFlow() {
|
inline const RegEx& EndScalarInFlow() {
|
||||||
static const RegEx e =
|
static const RegEx e =
|
||||||
(RegEx(':') + (BlankOrBreak() | RegEx())) | RegEx(",?[]{}", REGEX_OR);
|
(RegEx(':') + (BlankOrBreak() | RegEx() | RegEx(",]}", REGEX_OR))) |
|
||||||
|
RegEx(",?[]{}", REGEX_OR);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -246,13 +246,13 @@ struct ParserExceptionTestCase {
|
|||||||
|
|
||||||
TEST(NodeTest, IncompleteJson) {
|
TEST(NodeTest, IncompleteJson) {
|
||||||
std::vector<ParserExceptionTestCase> tests = {
|
std::vector<ParserExceptionTestCase> tests = {
|
||||||
{"JSON map without value", "{\"access\"", ErrorMsg::END_OF_MAP_FLOW},
|
{"JSON map without value", "{\"access\"", ErrorMsg::END_OF_MAP_FLOW},
|
||||||
{"JSON map with colon but no value", "{\"access\":",
|
{"JSON map with colon but no value", "{\"access\":",
|
||||||
ErrorMsg::END_OF_MAP_FLOW},
|
ErrorMsg::END_OF_MAP_FLOW},
|
||||||
{"JSON map with unclosed value quote", "{\"access\":\"",
|
{"JSON map with unclosed value quote", "{\"access\":\"",
|
||||||
ErrorMsg::END_OF_MAP_FLOW},
|
ErrorMsg::END_OF_MAP_FLOW},
|
||||||
{"JSON map without end brace", "{\"access\":\"abc\"",
|
{"JSON map without end brace", "{\"access\":\"abc\"",
|
||||||
ErrorMsg::END_OF_MAP_FLOW},
|
ErrorMsg::END_OF_MAP_FLOW},
|
||||||
};
|
};
|
||||||
for (const ParserExceptionTestCase& test : tests) {
|
for (const ParserExceptionTestCase& test : tests) {
|
||||||
try {
|
try {
|
||||||
@ -274,14 +274,16 @@ struct SingleNodeTestCase {
|
|||||||
|
|
||||||
TEST(NodeTest, SpecialFlow) {
|
TEST(NodeTest, SpecialFlow) {
|
||||||
std::vector<SingleNodeTestCase> tests = {
|
std::vector<SingleNodeTestCase> tests = {
|
||||||
{"[,]", NodeType::Sequence, 1, "[~]"},
|
{"[:]", NodeType::Sequence, 1, "[{~: ~}]"},
|
||||||
{"[a:]", NodeType::Sequence, 1, "[\"a:\"]"},
|
{"[a:]", NodeType::Sequence, 1, "[{a: ~}]"},
|
||||||
{"[:a]", NodeType::Sequence, 1, "[:a]"},
|
{"[:a]", NodeType::Sequence, 1, "[:a]"},
|
||||||
{"[:]", NodeType::Sequence, 1, "[\":\"]"},
|
{"[,]", NodeType::Sequence, 1, "[~]"},
|
||||||
{"{:}", NodeType::Map, 1, "{~: ~}"},
|
{"[a:,]", NodeType::Sequence, 1, "[{a: ~}]"},
|
||||||
{"{,}", NodeType::Map, 1, "{~: ~}"},
|
{"{:}", NodeType::Map, 1, "{~: ~}"},
|
||||||
{"{a:}", NodeType::Map, 1, "{\"a:\": ~}"},
|
{"{a:}", NodeType::Map, 1, "{a: ~}"},
|
||||||
{"{:a}", NodeType::Map, 1, "{:a: ~}"},
|
{"{:a}", NodeType::Map, 1, "{:a: ~}"},
|
||||||
|
{"{,}", NodeType::Map, 1, "{~: ~}"},
|
||||||
|
{"{a:,}", NodeType::Map, 1, "{a: ~}"},
|
||||||
};
|
};
|
||||||
for (const SingleNodeTestCase& test : tests) {
|
for (const SingleNodeTestCase& test : tests) {
|
||||||
Node node = Load(test.input);
|
Node node = Load(test.input);
|
||||||
|
|||||||
@ -552,7 +552,7 @@ const char *ex7_2 =
|
|||||||
|
|
||||||
const char *ex7_3 =
|
const char *ex7_3 =
|
||||||
"{\n"
|
"{\n"
|
||||||
" ? foo : ,\n"
|
" ? foo :,\n"
|
||||||
" : bar,\n"
|
" : bar,\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
@ -641,8 +641,8 @@ const char *ex7_17 =
|
|||||||
"{\n"
|
"{\n"
|
||||||
"unquoted : \"separate\",\n"
|
"unquoted : \"separate\",\n"
|
||||||
"http://foo.com,\n"
|
"http://foo.com,\n"
|
||||||
"omitted value: ,\n"
|
"omitted value:,\n"
|
||||||
" : omitted key,\n"
|
": omitted key,\n"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
const char *ex7_18 =
|
const char *ex7_18 =
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user