diff --git a/src/exp.h b/src/exp.h index bdfa6b8..301449e 100644 --- a/src/exp.h +++ b/src/exp.h @@ -110,7 +110,7 @@ inline const RegEx& Value() { return e; } inline const RegEx& ValueInFlow() { - static const RegEx e = RegEx(':') + (BlankOrBreak() | RegEx(",}", REGEX_OR)); + static const RegEx e = RegEx(':') + (BlankOrBreak() | RegEx(",]}", REGEX_OR)); return e; } inline const RegEx& ValueInJSONFlow() { @@ -164,7 +164,8 @@ inline const RegEx& EndScalar() { } inline const RegEx& EndScalarInFlow() { static const RegEx e = - (RegEx(':') + (BlankOrBreak() | RegEx())) | RegEx(",?[]{}", REGEX_OR); + (RegEx(':') + (BlankOrBreak() | RegEx() | RegEx(",]}", REGEX_OR))) | + RegEx(",?[]{}", REGEX_OR); return e; } diff --git a/test/integration/load_node_test.cpp b/test/integration/load_node_test.cpp index 0f03a9a..8f3bece 100644 --- a/test/integration/load_node_test.cpp +++ b/test/integration/load_node_test.cpp @@ -246,13 +246,13 @@ struct ParserExceptionTestCase { TEST(NodeTest, IncompleteJson) { std::vector tests = { - {"JSON map without value", "{\"access\"", ErrorMsg::END_OF_MAP_FLOW}, - {"JSON map with colon but no value", "{\"access\":", - ErrorMsg::END_OF_MAP_FLOW}, - {"JSON map with unclosed value quote", "{\"access\":\"", - ErrorMsg::END_OF_MAP_FLOW}, - {"JSON map without end brace", "{\"access\":\"abc\"", - ErrorMsg::END_OF_MAP_FLOW}, + {"JSON map without value", "{\"access\"", ErrorMsg::END_OF_MAP_FLOW}, + {"JSON map with colon but no value", "{\"access\":", + ErrorMsg::END_OF_MAP_FLOW}, + {"JSON map with unclosed value quote", "{\"access\":\"", + ErrorMsg::END_OF_MAP_FLOW}, + {"JSON map without end brace", "{\"access\":\"abc\"", + ErrorMsg::END_OF_MAP_FLOW}, }; for (const ParserExceptionTestCase& test : tests) { try { @@ -274,14 +274,16 @@ struct SingleNodeTestCase { TEST(NodeTest, SpecialFlow) { std::vector tests = { - {"[,]", NodeType::Sequence, 1, "[~]"}, - {"[a:]", NodeType::Sequence, 1, "[\"a:\"]"}, - {"[:a]", NodeType::Sequence, 1, "[:a]"}, - {"[:]", NodeType::Sequence, 1, "[\":\"]"}, - {"{:}", NodeType::Map, 1, "{~: ~}"}, - {"{,}", NodeType::Map, 1, "{~: ~}"}, - {"{a:}", NodeType::Map, 1, "{\"a:\": ~}"}, - {"{:a}", NodeType::Map, 1, "{:a: ~}"}, + {"[:]", NodeType::Sequence, 1, "[{~: ~}]"}, + {"[a:]", NodeType::Sequence, 1, "[{a: ~}]"}, + {"[:a]", NodeType::Sequence, 1, "[:a]"}, + {"[,]", NodeType::Sequence, 1, "[~]"}, + {"[a:,]", NodeType::Sequence, 1, "[{a: ~}]"}, + {"{:}", NodeType::Map, 1, "{~: ~}"}, + {"{a:}", NodeType::Map, 1, "{a: ~}"}, + {"{:a}", NodeType::Map, 1, "{:a: ~}"}, + {"{,}", NodeType::Map, 1, "{~: ~}"}, + {"{a:,}", NodeType::Map, 1, "{a: ~}"}, }; for (const SingleNodeTestCase& test : tests) { Node node = Load(test.input); diff --git a/test/specexamples.h b/test/specexamples.h index d9a50bf..46e2c4c 100644 --- a/test/specexamples.h +++ b/test/specexamples.h @@ -552,7 +552,7 @@ const char *ex7_2 = const char *ex7_3 = "{\n" - " ? foo : ,\n" + " ? foo :,\n" " : bar,\n" "}\n"; @@ -641,8 +641,8 @@ const char *ex7_17 = "{\n" "unquoted : \"separate\",\n" "http://foo.com,\n" - "omitted value: ,\n" - " : omitted key,\n" + "omitted value:,\n" + ": omitted key,\n" "}"; const char *ex7_18 =