improve engine tests

This commit is contained in:
Joao Paulo Magalhaes
2025-10-01 19:12:24 +01:00
parent 653eac9741
commit 7786d02ebb
11 changed files with 1689 additions and 1038 deletions

View File

@@ -56,15 +56,12 @@ size_t events_ints_to_testsuite(csubstr parsed_yaml,
auto maybe_append_tag = [&]{
if(has_tag)
{
#ifdef RYML_NO_COVERAGE__TO_BE_DELETED
if(tag.begins_with('<'))
{
append(" ");
append(tag);
}
else
#endif
if(tag.begins_with("!<"))
else if(tag.begins_with("!<"))
{
append(" ");
append(tag.sub(1));

View File

@@ -7,7 +7,7 @@ namespace c4 {
namespace yml {
ENGINE_TEST(DocEmpty,
(""),
"",
"+STR\n"
"-STR\n")
{
@@ -19,7 +19,7 @@ ENGINE_TEST(DocEmpty,
//-----------------------------------------------------------------------------
ENGINE_TEST(DocEmptyExpl,
("---\n"),
"---\n",
"+STR\n"
"+DOC ---\n"
"=VAL :\n"
@@ -37,7 +37,10 @@ ENGINE_TEST(DocEmptyExpl,
//-----------------------------------------------------------------------------
ENGINE_TEST(DocEmptyTerm1,
("...\n", ""),
"...\n"
,
""
,
"+STR\n"
"-STR\n")
{
@@ -46,7 +49,10 @@ ENGINE_TEST(DocEmptyTerm1,
}
ENGINE_TEST(DocEmptyTerm1Indented1,
(" ...\n", " ...\n"),
" ...\n"
,
" ...\n"
,
"+STR\n"
"+DOC\n"
"=VAL :...\n"
@@ -61,7 +67,10 @@ ENGINE_TEST(DocEmptyTerm1Indented1,
}
ENGINE_TEST(DocEmptyTerm2,
("...\n...\n", ""),
"...\n...\n"
,
""
,
"+STR\n"
"-STR\n")
{
@@ -70,8 +79,12 @@ ENGINE_TEST(DocEmptyTerm2,
}
ENGINE_TEST(DocEmptyTerm2Indented0,
(HAS_MULTILINE_SCALAR,
" ...\n...\n", " ...\n"),
HAS_MULTILINE_SCALAR
,
" ...\n...\n"
,
" ...\n"
,
"+STR\n"
"+DOC\n"
"=VAL :...\n"
@@ -86,8 +99,12 @@ ENGINE_TEST(DocEmptyTerm2Indented0,
}
ENGINE_TEST(DocEmptyTerm2Indented1,
(HAS_MULTILINE_SCALAR,
" ...\n ...\n", " ... ...\n"),
HAS_MULTILINE_SCALAR
,
" ...\n ...\n"
,
" ... ...\n"
,
"+STR\n"
"+DOC\n"
"=VAL :... ...\n"
@@ -102,7 +119,10 @@ ENGINE_TEST(DocEmptyTerm2Indented1,
}
ENGINE_TEST(DocEmptyTerm3,
("...\n...\n...\n", ""),
"...\n...\n...\n"
,
""
,
"+STR\n"
"-STR\n")
{
@@ -111,7 +131,10 @@ ENGINE_TEST(DocEmptyTerm3,
}
ENGINE_TEST(DocEmptyTerm3_1,
("...\n...\n..\n", "..\n"),
"...\n...\n..\n"
,
"..\n"
,
"+STR\n"
"+DOC\n"
"=VAL :..\n"
@@ -126,13 +149,14 @@ ENGINE_TEST(DocEmptyTerm3_1,
}
ENGINE_TEST(DocEmptyTerm4_2,
("...\n"
"...\n"
"......\n"
"...\n"
"...\n"
,
" ......\n"),
"...\n"
"...\n"
"......\n"
"...\n"
"...\n"
,
" ......\n"
,
"+STR\n"
"+DOC\n"
"=VAL :......\n"
@@ -150,7 +174,8 @@ ENGINE_TEST(DocEmptyTerm4_2,
//-----------------------------------------------------------------------------
ENGINE_TEST(DocEmptyExplMult,
("---\n---\n---\n"),
"---\n---\n---\n"
,
"+STR\n"
"+DOC ---\n"
"=VAL :\n"
@@ -179,7 +204,10 @@ ENGINE_TEST(DocEmptyExplMult,
//-----------------------------------------------------------------------------
ENGINE_TEST(DocEmptyExplMultImplFirst,
("foo\n--- bar\n--- baz\n", "--- foo\n--- bar\n--- baz\n"),
"foo\n--- bar\n--- baz\n"
,
"--- foo\n--- bar\n--- baz\n"
,
"+STR\n"
"+DOC\n"
"=VAL :foo\n"
@@ -209,7 +237,8 @@ ENGINE_TEST(DocEmptyExplMultImplFirst,
//-----------------------------------------------------------------------------
ENGINE_TEST(DocScalarPlain0,
("foo\n"),
"foo\n"
,
"+STR\n"
"+DOC\n"
"=VAL :foo\n"
@@ -224,7 +253,8 @@ ENGINE_TEST(DocScalarPlain0,
}
ENGINE_TEST(DocScalarPlain1,
("--- foo\n"),
"--- foo\n"
,
"+STR\n"
"+DOC ---\n"
"=VAL :foo\n"
@@ -239,7 +269,10 @@ ENGINE_TEST(DocScalarPlain1,
}
ENGINE_TEST(DocScalarPlain2,
("--- ---\n", "---\n ---\n"),
"--- ---\n"
,
"---\n ---\n"
,
"+STR\n"
"+DOC ---\n"
"=VAL :---\n"
@@ -254,7 +287,10 @@ ENGINE_TEST(DocScalarPlain2,
}
ENGINE_TEST(DocScalarPlain2_1,
("------\n", " ------\n"),
"------\n"
,
" ------\n"
,
"+STR\n"
"+DOC\n"
"=VAL :------\n"
@@ -269,7 +305,10 @@ ENGINE_TEST(DocScalarPlain2_1,
}
ENGINE_TEST(DocScalarPlain2_2,
("......\n", " ......\n"),
"......\n"
,
" ......\n"
,
"+STR\n"
"+DOC\n"
"=VAL :......\n"
@@ -284,7 +323,10 @@ ENGINE_TEST(DocScalarPlain2_2,
}
ENGINE_TEST(DocScalarPlain3,
("--- ...\n", "---\n ...\n"),
"--- ...\n"
,
"---\n ...\n"
,
"+STR\n"
"+DOC ---\n"
"=VAL :...\n"
@@ -299,7 +341,10 @@ ENGINE_TEST(DocScalarPlain3,
}
ENGINE_TEST(DocScalarPlain3_1,
("---...\n", " ---...\n"),
"---...\n"
,
" ---...\n"
,
"+STR\n"
"+DOC\n"
"=VAL :---...\n"
@@ -314,8 +359,11 @@ ENGINE_TEST(DocScalarPlain3_1,
}
ENGINE_TEST(DocScalarPlainMultiline0,
(HAS_MULTILINE_SCALAR,
"--- foo\n bar\n", "--- foo bar\n"),
HAS_MULTILINE_SCALAR,
"--- foo\n bar\n"
,
"--- foo bar\n"
,
"+STR\n"
"+DOC ---\n"
"=VAL :foo bar\n"
@@ -330,8 +378,10 @@ ENGINE_TEST(DocScalarPlainMultiline0,
}
ENGINE_TEST(DocScalarPlainMultiline0Indented,
(HAS_MULTILINE_SCALAR,
" --- foo\n bar\n", " --- foo bar\n"),
HAS_MULTILINE_SCALAR,
" --- foo\n bar\n"
, " --- foo bar\n"
,
"+STR\n"
"+DOC\n"
"=VAL :--- foo bar\n"
@@ -346,8 +396,12 @@ ENGINE_TEST(DocScalarPlainMultiline0Indented,
}
ENGINE_TEST(DocScalarPlainMultiline0Indented1,
(HAS_MULTILINE_SCALAR,
" --- foo\n bar\n", " --- foo bar\n"),
HAS_MULTILINE_SCALAR
,
" --- foo\n bar\n"
,
" --- foo bar\n"
,
"+STR\n"
"+DOC\n"
"=VAL :--- foo bar\n"
@@ -362,8 +416,12 @@ ENGINE_TEST(DocScalarPlainMultiline0Indented1,
}
ENGINE_TEST(DocScalarPlainMultiline,
(HAS_MULTILINE_SCALAR,
"foo\nbar\n\nfew\nbars", "foo bar\n\n few bars\n"),
HAS_MULTILINE_SCALAR
,
"foo\nbar\n\nfew\nbars"
,
"foo bar\n\n few bars\n"
,
"+STR\n"
"+DOC\n"
"=VAL :foo bar\\nfew bars\n"
@@ -378,8 +436,12 @@ ENGINE_TEST(DocScalarPlainMultiline,
}
ENGINE_TEST(DocScalarPlainMultilineComment0,
(HAS_MULTILINE_SCALAR,
"# comment\nfoo\nbar\n\nfew\nbars", "foo bar\n\n few bars\n"),
HAS_MULTILINE_SCALAR
,
"# comment\nfoo\nbar\n\nfew\nbars"
,
"foo bar\n\n few bars\n"
,
"+STR\n"
"+DOC\n"
"=VAL :foo bar\\nfew bars\n"
@@ -394,8 +456,12 @@ ENGINE_TEST(DocScalarPlainMultilineComment0,
}
ENGINE_TEST(DocScalarPlainMultilineComment1,
(HAS_MULTILINE_SCALAR,
"foo\nbar\n\nfew\nbars\n# comment\n", "foo bar\n\n few bars\n"),
HAS_MULTILINE_SCALAR
,
"foo\nbar\n\nfew\nbars\n# comment\n"
,
"foo bar\n\n few bars\n"
,
"+STR\n"
"+DOC\n"
"=VAL :foo bar\\nfew bars\n"
@@ -411,30 +477,30 @@ ENGINE_TEST(DocScalarPlainMultilineComment1,
ENGINE_TEST(DocScalarPlainIndentation,
(HAS_MULTILINE_SCALAR,
" foo\n"
" bar\n"
"baz\n"
"--- foo\n"
"bar\n"
"baz\n"
"---\n"
"- foo\n"
" bar\n"
"- baz\n"
"---\n"
"aaa: bbb\n"
" ccc\n"
"ddd: eee\n"
,
"--- foo bar baz\n"
"--- foo bar baz\n"
"---\n"
"- foo bar\n"
"- baz\n"
"---\n"
"aaa: bbb ccc\n"
"ddd: eee\n")
HAS_MULTILINE_SCALAR,
" foo\n"
" bar\n"
"baz\n"
"--- foo\n"
"bar\n"
"baz\n"
"---\n"
"- foo\n"
" bar\n"
"- baz\n"
"---\n"
"aaa: bbb\n"
" ccc\n"
"ddd: eee\n"
,
"--- foo bar baz\n"
"--- foo bar baz\n"
"---\n"
"- foo bar\n"
"- baz\n"
"---\n"
"aaa: bbb ccc\n"
"ddd: eee\n"
,
"+STR\n"
"+DOC\n"
@@ -489,7 +555,8 @@ ENGINE_TEST(DocScalarPlainIndentation,
//-----------------------------------------------------------------------------
ENGINE_TEST(DocScalarSQuoted,
("'foo'\n"),
"'foo'\n"
,
"+STR\n"
"+DOC\n"
"=VAL 'foo\n"
@@ -504,7 +571,11 @@ ENGINE_TEST(DocScalarSQuoted,
}
ENGINE_TEST(DocScalarSQuotedMultiline,
(HAS_MULTILINE_SCALAR, "'foo\nbar\nbaz\n\nbat'\n", "'foo bar baz\n\n bat'\n"),
HAS_MULTILINE_SCALAR
,
"'foo\nbar\nbaz\n\nbat'\n"
,
"'foo bar baz\n\n bat'\n",
"+STR\n"
"+DOC\n"
"=VAL 'foo bar baz\\nbat\n"
@@ -519,7 +590,12 @@ ENGINE_TEST(DocScalarSQuotedMultiline,
}
ENGINE_TEST(DocScalarSQuotedMultilineComment0,
(HAS_MULTILINE_SCALAR, "# a comment\n'foo\nbar\nbaz\n\nbat'\n", "'foo bar baz\n\n bat'\n"),
HAS_MULTILINE_SCALAR
,
"# a comment\n'foo\nbar\nbaz\n\nbat'\n"
,
"'foo bar baz\n\n bat'\n"
,
"+STR\n"
"+DOC\n"
"=VAL 'foo bar baz\\nbat\n"
@@ -534,7 +610,11 @@ ENGINE_TEST(DocScalarSQuotedMultilineComment0,
}
ENGINE_TEST(DocScalarSQuotedMultilineComment1,
(HAS_MULTILINE_SCALAR, "'foo\nbar\nbaz\n\nbat'\n# a comment\n", "'foo bar baz\n\n bat'\n"),
HAS_MULTILINE_SCALAR
,
"'foo\nbar\nbaz\n\nbat'\n# a comment\n"
,
"'foo bar baz\n\n bat'\n",
"+STR\n"
"+DOC\n"
"=VAL 'foo bar baz\\nbat\n"
@@ -552,7 +632,8 @@ ENGINE_TEST(DocScalarSQuotedMultilineComment1,
//-----------------------------------------------------------------------------
ENGINE_TEST(DocScalarDQuoted,
("\"foo\"\n"),
"\"foo\"\n"
,
"+STR\n"
"+DOC\n"
"=VAL \"foo\n"
@@ -567,9 +648,11 @@ ENGINE_TEST(DocScalarDQuoted,
}
ENGINE_TEST(DocScalarDQuotedMultiline,
(HAS_MULTILINE_SCALAR,
"\"foo\nbar\nbaz\n\nbat\"\n",
"\"foo bar baz\\nbat\"\n"),
HAS_MULTILINE_SCALAR
,
"\"foo\nbar\nbaz\n\nbat\"\n"
,
"\"foo bar baz\\nbat\"\n",
"+STR\n"
"+DOC\n"
"=VAL \"foo bar baz\\nbat\n"
@@ -584,9 +667,12 @@ ENGINE_TEST(DocScalarDQuotedMultiline,
}
ENGINE_TEST(DocScalarDQuotedMultilineComment0,
(HAS_MULTILINE_SCALAR,
"# a comment\n\"foo\nbar\nbaz\n\nbat\"\n",
"\"foo bar baz\\nbat\"\n"),
HAS_MULTILINE_SCALAR
,
"# a comment\n\"foo\nbar\nbaz\n\nbat\"\n"
,
"\"foo bar baz\\nbat\"\n"
,
"+STR\n"
"+DOC\n"
"=VAL \"foo bar baz\\nbat\n"
@@ -601,9 +687,12 @@ ENGINE_TEST(DocScalarDQuotedMultilineComment0,
}
ENGINE_TEST(DocScalarDQuotedMultilineComment1,
(HAS_MULTILINE_SCALAR,
"\"foo\nbar\nbaz\n\nbat\"\n# a comment\n",
"\"foo bar baz\\nbat\"\n"),
HAS_MULTILINE_SCALAR
,
"\"foo\nbar\nbaz\n\nbat\"\n# a comment\n"
,
"\"foo bar baz\\nbat\"\n"
,
"+STR\n"
"+DOC\n"
"=VAL \"foo bar baz\\nbat\n"
@@ -621,7 +710,10 @@ ENGINE_TEST(DocScalarDQuotedMultilineComment1,
//-----------------------------------------------------------------------------
ENGINE_TEST(DocScalarLiteral,
(HAS_MULTILINE_SCALAR, "|-\n foo\n"),
HAS_MULTILINE_SCALAR
,
"|-\n foo\n"
,
"+STR\n"
"+DOC\n"
"=VAL |foo\n"
@@ -636,7 +728,11 @@ ENGINE_TEST(DocScalarLiteral,
}
ENGINE_TEST(DocScalarLiteralComment0,
(HAS_MULTILINE_SCALAR, "# comment\n|-\n foo\n", "|-\n foo\n"),
HAS_MULTILINE_SCALAR
,
"# comment\n|-\n foo\n"
,
"|-\n foo\n",
"+STR\n"
"+DOC\n"
"=VAL |foo\n"
@@ -651,7 +747,12 @@ ENGINE_TEST(DocScalarLiteralComment0,
}
ENGINE_TEST(DocScalarLiteralComment1,
(HAS_MULTILINE_SCALAR, "|-\n foo\n# comment\n", "|-\n foo\n"),
HAS_MULTILINE_SCALAR
,
"|-\n foo\n# comment\n"
,
"|-\n foo\n"
,
"+STR\n"
"+DOC\n"
"=VAL |foo\n"
@@ -669,7 +770,10 @@ ENGINE_TEST(DocScalarLiteralComment1,
//-----------------------------------------------------------------------------
ENGINE_TEST(DocScalarFolded,
(HAS_MULTILINE_SCALAR, ">-\n foo\n"),
HAS_MULTILINE_SCALAR
,
">-\n foo\n"
,
"+STR\n"
"+DOC\n"
"=VAL >foo\n"
@@ -684,7 +788,12 @@ ENGINE_TEST(DocScalarFolded,
}
ENGINE_TEST(DocScalarFoldedComment0,
(HAS_MULTILINE_SCALAR, "# comment\n>-\n foo\n", ">-\n foo\n"),
HAS_MULTILINE_SCALAR
,
"# comment\n>-\n foo\n"
,
">-\n foo\n"
,
"+STR\n"
"+DOC\n"
"=VAL >foo\n"
@@ -699,7 +808,12 @@ ENGINE_TEST(DocScalarFoldedComment0,
}
ENGINE_TEST(DocScalarFoldedComment1,
(HAS_MULTILINE_SCALAR, ">-\n foo\n# comment\n", ">-\n foo\n"),
HAS_MULTILINE_SCALAR
,
">-\n foo\n# comment\n"
,
">-\n foo\n"
,
"+STR\n"
"+DOC\n"
"=VAL >foo\n"
@@ -717,7 +831,11 @@ ENGINE_TEST(DocScalarFoldedComment1,
//-----------------------------------------------------------------------------
ENGINE_TEST(ScalarMixedDoc,
(HAS_MULTILINE_SCALAR, R"(. "dquo" plain 'squo')", ". \"dquo\" plain 'squo'\n"),
HAS_MULTILINE_SCALAR,
". \"dquo\" plain 'squo'"
,
". \"dquo\" plain 'squo'\n"
,
"+STR\n"
"+DOC\n"
"=VAL :. \"dquo\" plain 'squo'\n"
@@ -732,7 +850,12 @@ ENGINE_TEST(ScalarMixedDoc,
}
ENGINE_TEST(ScalarMixedMap,
(HAS_MULTILINE_SCALAR, R"(foo: . "dquo" plain 'squo')", "foo: . \"dquo\" plain 'squo'\n"),
HAS_MULTILINE_SCALAR
,
"foo: . \"dquo\" plain 'squo'"
,
"foo: . \"dquo\" plain 'squo'\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -756,7 +879,8 @@ ENGINE_TEST(ScalarMixedMap,
//-----------------------------------------------------------------------------
ENGINE_TEST(DocStream,
("--- doc0\n--- 'doc1'\n--- \"doc2\"\n"),
"--- doc0\n--- 'doc1'\n--- \"doc2\"\n"
,
"+STR\n"
"+DOC ---\n"
"=VAL :doc0\n"
@@ -786,7 +910,10 @@ ENGINE_TEST(DocStream,
//-----------------------------------------------------------------------------
ENGINE_TEST(DocStreamImplicitDocFirst,
("doc0\n--- doc1\n--- doc2\n", "--- doc0\n--- doc1\n--- doc2\n"),
"doc0\n--- doc1\n--- doc2\n"
,
"--- doc0\n--- doc1\n--- doc2\n"
,
"+STR\n"
"+DOC\n"
"=VAL :doc0\n"
@@ -816,20 +943,22 @@ ENGINE_TEST(DocStreamImplicitDocFirst,
//-----------------------------------------------------------------------------
ENGINE_TEST(SuddenDoc0,
("- map:\n"
" foo: bar\n"
"...\n"
"seq:\n"
" - a\n"
" - b\n"
"...\n",
"---\n"
"- map:\n"
" foo: bar\n"
"---\n"
"seq:\n"
" - a\n"
" - b\n"),
"- map:\n"
" foo: bar\n"
"...\n"
"seq:\n"
" - a\n"
" - b\n"
"...\n"
,
"---\n"
"- map:\n"
" foo: bar\n"
"---\n"
"seq:\n"
" - a\n"
" - b\n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -879,70 +1008,71 @@ ENGINE_TEST(SuddenDoc0,
}
ENGINE_TEST(SuddenDoc1,
("map:\n"
" nested:\n"
" nested more:\n"
" nested even more:\n"
" - now inside a seq:\n"
" another map:\n"
" - another seq\n"
" - etc\n"
"---\n"
"map:\n"
" nested:\n"
" nested more:\n"
" nested even more:\n"
" - now inside a seq:\n"
" another map: the value\n"
"---\n"
"map:\n"
" nested:\n"
" nested more:\n"
" nested even more:\n"
" - now inside a seq:\n"
" another map:\n"
" - another seq\n"
" - etc\n"
"...\n"
"map:\n"
" nested:\n"
" nested more:\n"
" nested even more:\n"
" - now inside a seq:\n"
" another map: the value\n"
"...\n",
"---\n"
"map:\n"
" nested:\n"
" nested more:\n"
" nested even more:\n"
" - now inside a seq:\n"
" another map:\n"
" - another seq\n"
" - etc\n"
"---\n"
"map:\n"
" nested:\n"
" nested more:\n"
" nested even more:\n"
" - now inside a seq:\n"
" another map: the value\n"
"---\n"
"map:\n"
" nested:\n"
" nested more:\n"
" nested even more:\n"
" - now inside a seq:\n"
" another map:\n"
" - another seq\n"
" - etc\n"
"---\n"
"map:\n"
" nested:\n"
" nested more:\n"
" nested even more:\n"
" - now inside a seq:\n"
" another map: the value\n"),
"map:\n"
" nested:\n"
" nested more:\n"
" nested even more:\n"
" - now inside a seq:\n"
" another map:\n"
" - another seq\n"
" - etc\n"
"---\n"
"map:\n"
" nested:\n"
" nested more:\n"
" nested even more:\n"
" - now inside a seq:\n"
" another map: the value\n"
"---\n"
"map:\n"
" nested:\n"
" nested more:\n"
" nested even more:\n"
" - now inside a seq:\n"
" another map:\n"
" - another seq\n"
" - etc\n"
"...\n"
"map:\n"
" nested:\n"
" nested more:\n"
" nested even more:\n"
" - now inside a seq:\n"
" another map: the value\n"
"...\n",
"---\n"
"map:\n"
" nested:\n"
" nested more:\n"
" nested even more:\n"
" - now inside a seq:\n"
" another map:\n"
" - another seq\n"
" - etc\n"
"---\n"
"map:\n"
" nested:\n"
" nested more:\n"
" nested even more:\n"
" - now inside a seq:\n"
" another map: the value\n"
"---\n"
"map:\n"
" nested:\n"
" nested more:\n"
" nested even more:\n"
" - now inside a seq:\n"
" another map:\n"
" - another seq\n"
" - etc\n"
"---\n"
"map:\n"
" nested:\n"
" nested more:\n"
" nested even more:\n"
" - now inside a seq:\n"
" another map: the value\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -1110,7 +1240,6 @@ ENGINE_TEST(SuddenDoc1,
___(ps.end_stream());
}
} // namespace yml
} // namespace c4

View File

@@ -9,7 +9,8 @@ namespace yml {
//-----------------------------------------------------------------------------
ENGINE_TEST(SimpleMapFlow,
("{foo: bar,foo2: bar2}"),
"{foo: bar,foo2: bar2}"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -35,7 +36,12 @@ ENGINE_TEST(SimpleMapFlow,
}
ENGINE_TEST(NestedMapFlow,
(HAS_CONTAINER_KEYS, Location(1,1,2), "{{}: {}}"),
HAS_CONTAINER_KEYS
,
Location(1,1,2)
,
"{{}: {}}"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -60,7 +66,11 @@ ENGINE_TEST(NestedMapFlow,
}
ENGINE_TEST(NestedMap3FlowEmpty,
(HAS_CONTAINER_KEYS, Location(1,1,2), "{{{}: {}}: {{}: {}}}"),
HAS_CONTAINER_KEYS
,
Location(1,1,2)
,
"{{{}: {}}: {{}: {}}}",
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -101,7 +111,10 @@ ENGINE_TEST(NestedMap3FlowEmpty,
}
ENGINE_TEST(SimpleMapFlowMultiline,
("{\nfoo:\n bar\n,\nfoo2:\nbar2\n}", "{foo: bar,foo2: bar2}"),
"{\nfoo:\n bar\n,\nfoo2:\nbar2\n}"
,
"{foo: bar,foo2: bar2}"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -129,7 +142,6 @@ ENGINE_TEST(SimpleMapFlowMultiline,
ENGINE_TEST_ERRLOC(SimpleMapFlowErr0, Location(1,1,2), "{")
ENGINE_TEST_ERRLOC(SimpleMapFlowErr1, Location(5,1,6), "{a: b")
//-----------------------------------------------------------------------------
ENGINE_TEST_ERRLOC(SimpleMapBlockSameLine0Err, Location(5,1,6), "a: b: c")
@@ -139,19 +151,20 @@ ENGINE_TEST_ERRLOC(SimpleMapBlockSameLine3Err, Location(2,1,3), ": : :")
ENGINE_TEST_ERRLOC(SimpleMapBlockSameLine4Err, Location(2,1,3), ": : : :")
ENGINE_TEST_ERRLOC(SimpleMapBlockSameLine5Err, Location(9,1,10), "'a': 'b': 'c'")
ENGINE_TEST_ERRLOC(SimpleMapBlockSameLine6Err, Location(9,1,10), "\"a\": \"b\": \"c\"")
ENGINE_TEST(SimpleMapBlockSameLine7, (HAS_MULTILINE_SCALAR,
ENGINE_TEST(SimpleMapBlockSameLine7, HAS_MULTILINE_SCALAR,
""
"? |-\n"
" a\n"
": b: c\n"
"",
""
,
""
"? |-\n"
" a\n"
":\n"
" b: c\n"
""
),
,
""
"+STR\n"
"+DOC\n"
@@ -182,7 +195,8 @@ ENGINE_TEST(SimpleMapBlockSameLine7, (HAS_MULTILINE_SCALAR,
//-----------------------------------------------------------------------------
ENGINE_TEST(SimpleMapBlock,
("foo: bar\nfoo2: bar2\nfoo3: bar3\n"),
"foo: bar\nfoo2: bar2\nfoo3: bar3\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -213,7 +227,10 @@ ENGINE_TEST(SimpleMapBlock,
}
ENGINE_TEST(SimpleMapBlockEmptyVals,
("a:\nb:\nc:\nd:\n", "a: \nb: \nc: \nd: \n"),
"a:\nb:\nc:\nd:\n"
,
"a: \nb: \nc: \nd: \n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -249,7 +266,8 @@ ENGINE_TEST(SimpleMapBlockEmptyVals,
}
ENGINE_TEST(SimpleMapBlockEmptyKeys,
(": a\n: b\n: c\n: d\n"),
": a\n: b\n: c\n: d\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -285,7 +303,10 @@ ENGINE_TEST(SimpleMapBlockEmptyKeys,
}
ENGINE_TEST(SimpleMapBlockEmpty,
(":\n:\n:\n:\n", ": \n: \n: \n: \n"),
":\n:\n:\n:\n"
,
": \n: \n: \n: \n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -321,22 +342,24 @@ ENGINE_TEST(SimpleMapBlockEmpty,
}
ENGINE_TEST(SimpleMapIndentlessSeq,
("foo:\n"
"- bar\n"
"-\n"
"baz: qux\n"
"foo2:\n"
"- bar2\n"
"- \n"
"baz2: qux2\n",
"foo:\n"
" - bar\n"
" - \n"
"baz: qux\n"
"foo2:\n"
" - bar2\n"
" - \n"
"baz2: qux2\n"),
"foo:\n"
"- bar\n"
"-\n"
"baz: qux\n"
"foo2:\n"
"- bar2\n"
"- \n"
"baz2: qux2\n"
,
"foo:\n"
" - bar\n"
" - \n"
"baz: qux\n"
"foo2:\n"
" - bar2\n"
" - \n"
"baz2: qux2\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -389,8 +412,9 @@ ENGINE_TEST(SimpleMapIndentlessSeq,
//-----------------------------------------------------------------------------
ENGINE_TEST(SimpleMapContainerKeyFlow,
(HAS_CONTAINER_KEYS,
"{{this: is, a: keymap}: [and,now,a,seq,val]}"),
HAS_CONTAINER_KEYS,
"{{this: is, a: keymap}: [and,now,a,seq,val]}"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -438,8 +462,9 @@ ENGINE_TEST(SimpleMapContainerKeyFlow,
}
ENGINE_TEST(SimpleMapContainerKey1Block0_0,
(HAS_CONTAINER_KEYS,
"{this: is, a: keymap}: [and,now,a,seq,val]"),
HAS_CONTAINER_KEYS,
"{this: is, a: keymap}: [and,now,a,seq,val]"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -487,8 +512,9 @@ ENGINE_TEST(SimpleMapContainerKey1Block0_0,
}
ENGINE_TEST(SimpleMapContainerKey1Block0_1,
(HAS_CONTAINER_KEYS,
"{this: is, a: keymap}: [and,now,a,seq,val]"),
HAS_CONTAINER_KEYS,
"{this: is, a: keymap}: [and,now,a,seq,val]"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -536,8 +562,9 @@ ENGINE_TEST(SimpleMapContainerKey1Block0_1,
}
ENGINE_TEST(SimpleMapContainerKey1Block1_0,
(HAS_CONTAINER_KEYS,
"[this,is,a,seq,key]: [and,now,a,seq,val]"),
HAS_CONTAINER_KEYS,
"[this,is,a,seq,key]: [and,now,a,seq,val]"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -590,8 +617,9 @@ ENGINE_TEST(SimpleMapContainerKey1Block1_0,
}
ENGINE_TEST(SimpleMapContainerKey1Block1_1,
(HAS_CONTAINER_KEYS,
"[this,is,a,seq,key]: [and,now,a,seq,val]"),
HAS_CONTAINER_KEYS,
"[this,is,a,seq,key]: [and,now,a,seq,val]"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -644,8 +672,9 @@ ENGINE_TEST(SimpleMapContainerKey1Block1_1,
}
ENGINE_TEST(SimpleMapContainerKey1Block2_0,
(HAS_CONTAINER_KEYS,
"{this: is, a: keymap}: [and,now,a,seq,val]"),
HAS_CONTAINER_KEYS,
"{this: is, a: keymap}: [and,now,a,seq,val]"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -693,8 +722,9 @@ ENGINE_TEST(SimpleMapContainerKey1Block2_0,
}
ENGINE_TEST(SimpleMapContainerKey1Block2_1,
(HAS_CONTAINER_KEYS,
"{this: is, a: keymap}: [and,now,a,seq,val]"),
HAS_CONTAINER_KEYS,
"{this: is, a: keymap}: [and,now,a,seq,val]"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -742,11 +772,12 @@ ENGINE_TEST(SimpleMapContainerKey1Block2_1,
}
ENGINE_TEST(SimpleMapContainerKey1Block3_0,
(HAS_CONTAINER_KEYS,
"---\n"
"{a: map}: [a,seq]\n"
"---\n"
"[A,SEQ]: {A: MAP}\n"),
HAS_CONTAINER_KEYS,
"---\n"
"{a: map}: [a,seq]\n"
"---\n"
"[A,SEQ]: {A: MAP}\n"
,
"+STR\n"
"+DOC ---\n"
"+MAP\n"
@@ -805,11 +836,12 @@ ENGINE_TEST(SimpleMapContainerKey1Block3_0,
}
ENGINE_TEST(SimpleMapContainerKey1Block3_1,
(HAS_CONTAINER_KEYS,
"---\n"
"{a: map}: [a,seq]\n"
"---\n"
"[A,SEQ]: {A: MAP}\n"),
HAS_CONTAINER_KEYS,
"---\n"
"{a: map}: [a,seq]\n"
"---\n"
"[A,SEQ]: {A: MAP}\n"
,
"+STR\n"
"+DOC ---\n"
"+MAP\n"
@@ -872,11 +904,12 @@ ENGINE_TEST(SimpleMapContainerKey1Block3_1,
// where it is parsed in UNK state. This one has those tokens already
// in RMAP|BLCK|RKEY state, ie, they don't come first.
ENGINE_TEST(SimpleMapContainerKey2Block_1,
(HAS_CONTAINER_KEYS,
"\n"
"foo: bar\n"
"!maptag &mapanchor {this: is, a: keymap}: [and,now,a,seq,val]\n"
"!seqtag &seqanchor [now, reversed]: {of: course}\n"),
HAS_CONTAINER_KEYS,
"\n"
"foo: bar\n"
"!maptag &mapanchor {this: is, a: keymap}: [and,now,a,seq,val]\n"
"!seqtag &seqanchor [now, reversed]: {of: course}\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -953,7 +986,8 @@ ENGINE_TEST(SimpleMapContainerKey2Block_1,
//-----------------------------------------------------------------------------
ENGINE_TEST(MapMapFlow,
("{map1: {foo1: bar1,FOO1: BAR1},map2: {foo2: bar2,FOO2: BAR2}}"),
"{map1: {foo1: bar1,FOO1: BAR1},map2: {foo2: bar2,FOO2: BAR2}}"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -1004,12 +1038,13 @@ ENGINE_TEST(MapMapFlow,
//-----------------------------------------------------------------------------
ENGINE_TEST(MapMapBlock,
("map1:\n"
" foo1: bar1\n"
" FOO1: BAR1\n"
"map2:\n"
" foo2: bar2\n"
" FOO2: BAR2\n"),
"map1:\n"
" foo1: bar1\n"
" FOO1: BAR1\n"
"map2:\n"
" foo2: bar2\n"
" FOO2: BAR2\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -1057,20 +1092,21 @@ ENGINE_TEST(MapMapBlock,
}
ENGINE_TEST(MapMapMapBlock,
("map0:\n"
" map01:\n"
" foo01: bar01\n"
" FOO01: BAR01\n"
" map02:\n"
" foo02: bar02\n"
" FOO02: BAR02\n"
" child02:\n"
" foo020: bar020\n"
" foo021: bar021\n"
"map1:\n"
" map11:\n"
" foo11: bar11\n"
" FOO11: BAR11\n"),
"map0:\n"
" map01:\n"
" foo01: bar01\n"
" FOO01: BAR01\n"
" map02:\n"
" foo02: bar02\n"
" FOO02: BAR02\n"
" child02:\n"
" foo020: bar020\n"
" foo021: bar021\n"
"map1:\n"
" map11:\n"
" foo11: bar11\n"
" FOO11: BAR11\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -1165,7 +1201,9 @@ ENGINE_TEST(MapMapMapBlock,
//-----------------------------------------------------------------------------
ENGINE_TEST(MapKeyFlow,
(HAS_CONTAINER_KEYS, Location(1, 1, 2), "{{foo: bar}: baz}"),
HAS_CONTAINER_KEYS, Location(1, 1, 2),
"{{foo: bar}: baz}"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -1192,7 +1230,9 @@ ENGINE_TEST(MapKeyFlow,
}
ENGINE_TEST(MapKeyBlock,
(HAS_CONTAINER_KEYS, Location(6,1,7), "? foo: bar\n: baz"),
HAS_CONTAINER_KEYS, Location(6,1,7),
"? foo: bar\n: baz"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -1219,7 +1259,9 @@ ENGINE_TEST(MapKeyBlock,
}
ENGINE_TEST(MapKeyBlockFlow,
(HAS_CONTAINER_KEYS, Location(2,1,3), "? {foo: bar}\n: baz"),
HAS_CONTAINER_KEYS, Location(2,1,3),
"? {foo: bar}\n: baz"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -1246,7 +1288,9 @@ ENGINE_TEST(MapKeyBlockFlow,
}
ENGINE_TEST(SeqKeyFlow,
(HAS_CONTAINER_KEYS, Location(1,1,2), "{[foo, bar]: baz}"),
HAS_CONTAINER_KEYS, Location(1,1,2),
"{[foo, bar]: baz}"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -1274,11 +1318,12 @@ ENGINE_TEST(SeqKeyFlow,
}
ENGINE_TEST(SeqKeyBlock,
(HAS_CONTAINER_KEYS, Location(3,2,2),
"?\n"
" - foo\n"
" - bar\n"
": baz\n"),
HAS_CONTAINER_KEYS, Location(3,2,2),
"?\n"
" - foo\n"
" - bar\n"
": baz\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -1306,9 +1351,10 @@ ENGINE_TEST(SeqKeyBlock,
}
ENGINE_TEST(SeqKeyBlockFlow,
(HAS_CONTAINER_KEYS, Location(2,1,3),
"? [foo, bar]\n"
": baz\n"),
HAS_CONTAINER_KEYS, Location(2,1,3),
"? [foo, bar]\n"
": baz\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -1336,13 +1382,14 @@ ENGINE_TEST(SeqKeyBlockFlow,
}
ENGINE_TEST(SeqKeyBlock2,
(HAS_CONTAINER_KEYS, Location(2,2,1),
"?\n"
"- foo\n"
"- bar\n"
":\n"
"- baz\n"
"- bat\n"),
HAS_CONTAINER_KEYS, Location(2,2,1),
"?\n"
"- foo\n"
"- bar\n"
":\n"
"- baz\n"
"- bat\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -1377,13 +1424,14 @@ ENGINE_TEST(SeqKeyBlock2,
}
ENGINE_TEST(SeqKeyBlock3,
(HAS_CONTAINER_KEYS, Location(3,2,2),
"?\n"
" - foo\n"
" - bar\n"
":\n"
" - baz\n"
" - bat\n"),
HAS_CONTAINER_KEYS, Location(3,2,2),
"?\n"
" - foo\n"
" - bar\n"
":\n"
" - baz\n"
" - bat\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -1418,10 +1466,11 @@ ENGINE_TEST(SeqKeyBlock3,
}
ENGINE_TEST(MapKeyBlock4Squo0,
(HAS_CONTAINER_KEYS,
"\n"
"? 'foo' : bar\n"
": baz\n"),
HAS_CONTAINER_KEYS,
"\n"
"? 'foo' : bar\n"
": baz\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -1448,11 +1497,12 @@ ENGINE_TEST(MapKeyBlock4Squo0,
}
ENGINE_TEST(MapKeyBlock4Squo1,
(HAS_CONTAINER_KEYS,
"&blockanchor\n"
"? &mapkey\n"
" &scalarkey 'foo' : bar\n"
": baz\n"),
HAS_CONTAINER_KEYS,
"&blockanchor\n"
"? &mapkey\n"
" &scalarkey 'foo' : bar\n"
": baz\n"
,
"+STR\n"
"+DOC\n"
"+MAP &blockanchor\n"
@@ -1482,10 +1532,11 @@ ENGINE_TEST(MapKeyBlock4Squo1,
}
ENGINE_TEST(MapKeyBlock4Dquo0,
(HAS_CONTAINER_KEYS,
"\n"
"? \"foo\" : bar\n"
": baz\n"),
HAS_CONTAINER_KEYS,
"\n"
"? \"foo\" : bar\n"
": baz\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -1512,11 +1563,12 @@ ENGINE_TEST(MapKeyBlock4Dquo0,
}
ENGINE_TEST(MapKeyBlock4Dquo1,
(HAS_CONTAINER_KEYS,
"&blockanchor\n"
"? &mapkey\n"
" &scalarkey \"foo\" : bar\n"
": baz\n"),
HAS_CONTAINER_KEYS,
"&blockanchor\n"
"? &mapkey\n"
" &scalarkey \"foo\" : bar\n"
": baz\n"
,
"+STR\n"
"+DOC\n"
"+MAP &blockanchor\n"
@@ -1546,10 +1598,11 @@ ENGINE_TEST(MapKeyBlock4Dquo1,
}
ENGINE_TEST(MapKeyBlock4Ref0,
("\n"
"? *ref\n"
": baz\n",
"*ref : baz\n"),
"\n"
"? *ref\n"
": baz\n",
"*ref : baz\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -1570,11 +1623,12 @@ ENGINE_TEST(MapKeyBlock4Ref0,
}
ENGINE_TEST(MapKeyBlock4Ref1,
(HAS_CONTAINER_KEYS,
"\n"
"? &mapanchor\n"
" *ref : bar\n"
": baz\n"),
HAS_CONTAINER_KEYS,
"\n"
"? &mapanchor\n"
" *ref : bar\n"
": baz\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -1601,7 +1655,6 @@ ENGINE_TEST(MapKeyBlock4Ref1,
___(ps.end_stream());
}
} // namespace yml
} // namespace c4

View File

@@ -10,7 +10,8 @@ namespace yml {
//-----------------------------------------------------------------------------
ENGINE_TEST(SimpleSeqFlow,
("[foo,bar,baz]"),
"[foo,bar,baz]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -46,7 +47,8 @@ ENGINE_TEST_ERRLOC(SimpleSeqFlowErr7, Location(8,1,9), "[[a,b,c]")
ENGINE_TEST(NestedSeqFlowEmpty,
("[[]]"),
"[[]]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -67,7 +69,8 @@ ENGINE_TEST(NestedSeqFlowEmpty,
}
ENGINE_TEST(NestedSeq3FlowEmpty,
("[[[]]]"),
"[[[]]]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -92,7 +95,8 @@ ENGINE_TEST(NestedSeq3FlowEmpty,
}
ENGINE_TEST(NestedSeq4FlowEmpty,
("[[[[]]]]"),
"[[[[]]]]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -121,7 +125,10 @@ ENGINE_TEST(NestedSeq4FlowEmpty,
}
ENGINE_TEST(SimpleSeqFlowMultiline,
("[\nfoo\n,\nbar\n,\nbaz\n]", "[foo,bar,baz]"),
"[\nfoo\n,\nbar\n,\nbaz\n]"
,
"[foo,bar,baz]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -149,7 +156,8 @@ ENGINE_TEST(SimpleSeqFlowMultiline,
//-----------------------------------------------------------------------------
ENGINE_TEST(SimpleSeqBlock,
("- foo\n- bar\n- baz\n"),
"- foo\n- bar\n- baz\n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -174,8 +182,10 @@ ENGINE_TEST(SimpleSeqBlock,
}
ENGINE_TEST(SimpleSeqBlock2,
("- [foo, bar, baz]\n- {foo: bar,baz}\n",
"- [foo,bar,baz]\n- {foo: bar,baz: }\n"),
"- [foo, bar, baz]\n- {foo: bar,baz}\n"
,
"- [foo,bar,baz]\n- {foo: bar,baz: }\n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -219,11 +229,11 @@ ENGINE_TEST(SimpleSeqBlock2,
ENGINE_TEST(SimpleSeqBlockPlainScalar0,
(HAS_MULTILINE_SCALAR,
"- a\n"
" b\n"
,
"- a b\n")
HAS_MULTILINE_SCALAR,
"- a\n"
" b\n"
,
"- a b\n"
,
"+STR\n"
"+DOC\n"
@@ -243,10 +253,11 @@ ENGINE_TEST(SimpleSeqBlockPlainScalar0,
}
ENGINE_TEST(SimpleSeqBlockPlainScalar1,
(HAS_MULTILINE_SCALAR,
HAS_MULTILINE_SCALAR,
"- a\n"
" - b - c\n",
"- a - b - c\n"),
"- a - b - c\n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -265,11 +276,13 @@ ENGINE_TEST(SimpleSeqBlockPlainScalar1,
}
ENGINE_TEST(SimpleSeqBlockComment0,
("- &wtf\n"
" # this is a comment\n"
" foo\n"
"\n",
"- &wtf foo\n"),
"- &wtf\n"
" # this is a comment\n"
" foo\n"
"\n"
,
"- &wtf foo\n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -289,10 +302,13 @@ ENGINE_TEST(SimpleSeqBlockComment0,
}
ENGINE_TEST(SimpleSeqBlockComment1,
("- &wtf\n"
" foo\n"
" # this is a comment\n"
"\n", "- &wtf foo\n"),
"- &wtf\n"
" foo\n"
" # this is a comment\n"
"\n"
,
"- &wtf foo\n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -312,7 +328,10 @@ ENGINE_TEST(SimpleSeqBlockComment1,
}
ENGINE_TEST(SimpleSeqBlockEmptyScalars,
("-\n-\n-\n-\n", "- \n- \n- \n- \n"),
"-\n-\n-\n-\n"
,
"- \n- \n- \n- \n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -340,9 +359,12 @@ ENGINE_TEST(SimpleSeqBlockEmptyScalars,
}
ENGINE_TEST(SimpleSeqBlockEmptyLiterals,
(HAS_MULTILINE_SCALAR,
"- |\n- |\n- |\n- |\n",
"- |-\n- |-\n- |-\n- |-\n"),
HAS_MULTILINE_SCALAR
,
"- |\n- |\n- |\n- |\n"
,
"- |-\n- |-\n- |-\n- |-\n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -370,9 +392,11 @@ ENGINE_TEST(SimpleSeqBlockEmptyLiterals,
}
ENGINE_TEST(SimpleSeqBlockEmptyFolded,
(HAS_MULTILINE_SCALAR,
"- >\n- >\n- >\n- >\n",
"- >-\n- >-\n- >-\n- >-\n"),
HAS_MULTILINE_SCALAR,
"- >\n- >\n- >\n- >\n"
,
"- >-\n- >-\n- >-\n- >-\n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -402,7 +426,10 @@ ENGINE_TEST(SimpleSeqBlockEmptyFolded,
//-----------------------------------------------------------------------------
ENGINE_TEST(SeqSeqFlow,
("[[foo1,bar1,baz1],\n[foo2,bar2,baz2]]", "[[foo1,bar1,baz1],[foo2,bar2,baz2]]"),
"[[foo1,bar1,baz1],\n[foo2,bar2,baz2]]"
,
"[[foo1,bar1,baz1],[foo2,bar2,baz2]]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -444,16 +471,16 @@ ENGINE_TEST(SeqSeqFlow,
}
ENGINE_TEST(SeqBlockSpace, (HAS_MULTILINE_SCALAR,
""
"- a\n"
" - b\n"
""
,
""
"- a - b\n"
""
),
ENGINE_TEST(SeqBlockSpace, HAS_MULTILINE_SCALAR,
""
"- a\n"
" - b\n"
""
,
""
"- a - b\n"
""
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -472,13 +499,12 @@ ENGINE_TEST(SeqBlockSpace, (HAS_MULTILINE_SCALAR,
}
#ifdef RYML_FIX_THIS
ENGINE_TEST(SeqBlockTab,
(HAS_MULTILINE_SCALAR,
""
"- a\n"
"\t- b\n"
""
),
ENGINE_TEST(SeqBlockTab, HAS_MULTILINE_SCALAR,
""
"- a\n"
"\t- b\n"
""
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -501,12 +527,13 @@ ENGINE_TEST(SeqBlockTab,
//-----------------------------------------------------------------------------
ENGINE_TEST(SeqSeqBlock,
("- - foo1\n"
" - bar1\n"
" - baz1\n"
"- - foo2\n"
" - bar2\n"
" - baz2\n"),
"- - foo1\n"
" - bar1\n"
" - baz1\n"
"- - foo2\n"
" - bar2\n"
" - baz2\n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -548,13 +575,14 @@ ENGINE_TEST(SeqSeqBlock,
}
ENGINE_TEST(SeqSeqSeqBlock,
("- - - foo1\n"
" - bar1\n"
" - baz1\n"
" - - foo2\n"
" - bar2\n"
" - baz2\n"
"- back\n"),
"- - - foo1\n"
" - bar1\n"
" - baz1\n"
" - - foo2\n"
" - bar2\n"
" - baz2\n"
"- back\n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -603,12 +631,13 @@ ENGINE_TEST(SeqSeqSeqBlock,
}
ENGINE_TEST(SeqMapBlock,
("- foo: 1\n"
" bar: 2\n"
"- foo: 10\n"
" bar: 20\n"
"- foo: 100\n"
" bar: 200\n"),
"- foo: 1\n"
" bar: 2\n"
"- foo: 10\n"
" bar: 20\n"
"- foo: 100\n"
" bar: 200\n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"

View File

@@ -9,7 +9,8 @@ namespace yml {
//-----------------------------------------------------------------------------
ENGINE_TEST(AnchorDocVal,
("&val a\n"),
"&val a\n"
,
"+STR\n"
"+DOC\n"
"=VAL &val :a\n"
@@ -28,7 +29,8 @@ ENGINE_TEST(AnchorDocVal,
//-----------------------------------------------------------------------------
ENGINE_TEST(AnchorDocRef,
("*a\n"),
"*a\n"
,
"+STR\n"
"+DOC\n"
"=ALI *a\n"
@@ -46,7 +48,8 @@ ENGINE_TEST(AnchorDocRef,
//-----------------------------------------------------------------------------
ENGINE_TEST(AnchorExplDocVal,
("&val a\n"),
"&val a\n"
,
"+STR\n"
"+DOC\n"
"=VAL &val :a\n"
@@ -65,7 +68,8 @@ ENGINE_TEST(AnchorExplDocVal,
//-----------------------------------------------------------------------------
ENGINE_TEST(AnchorSeqBlock,
("&seq\n- &val1 val1\n- &val2 val2\n"),
"&seq\n- &val1 val1\n- &val2 val2\n"
,
"+STR\n"
"+DOC\n"
"+SEQ &seq\n"
@@ -90,12 +94,13 @@ ENGINE_TEST(AnchorSeqBlock,
}
ENGINE_TEST(AnchorSeqMapBlock,
("&seq\n"
"- &key1 key1: &val1 val1\n"
" &key2 key2: &val2 val2\n"
"- &map2\n"
" &key10 key10: &val10 val10\n"
" &key20 key20: &val20 val20\n"),
"&seq\n"
"- &key1 key1: &val1 val1\n"
" &key2 key2: &val2 val2\n"
"- &map2\n"
" &key10 key10: &val10 val10\n"
" &key20 key20: &val20 val20\n"
,
"+STR\n"
"+DOC\n"
"+SEQ &seq\n"
@@ -149,7 +154,10 @@ ENGINE_TEST(AnchorSeqMapBlock,
}
ENGINE_TEST(AnchorSeqFlow,
("&seq [&val1 val1,\n&val2 val2]", "&seq [&val1 val1,&val2 val2]"),
"&seq [&val1 val1,\n&val2 val2]"
,
"&seq [&val1 val1,&val2 val2]"
,
"+STR\n"
"+DOC\n"
"+SEQ [] &seq\n"
@@ -174,7 +182,8 @@ ENGINE_TEST(AnchorSeqFlow,
}
ENGINE_TEST(AnchorSeqBlockWithRef,
("&seq\n- &val1 val1\n- *val1\n"),
"&seq\n- &val1 val1\n- *val1\n"
,
"+STR\n"
"+DOC\n"
"+SEQ &seq\n"
@@ -198,7 +207,10 @@ ENGINE_TEST(AnchorSeqBlockWithRef,
}
ENGINE_TEST(AnchorSeqFlowWithRef,
("&seq [&val1 val1,*val1]", "&seq [&val1 val1,*val1]"),
"&seq [&val1 val1,*val1]"
,
"&seq [&val1 val1,*val1]"
,
"+STR\n"
"+DOC\n"
"+SEQ [] &seq\n"
@@ -222,7 +234,10 @@ ENGINE_TEST(AnchorSeqFlowWithRef,
}
ENGINE_TEST(AnchorSeqFlowWithRefMultiLine,
("&seq\n[\n&val1 val1\n,*val1\n]", "&seq [&val1 val1,*val1]"),
"&seq\n[\n&val1 val1\n,*val1\n]"
,
"&seq [&val1 val1,*val1]"
,
"+STR\n"
"+DOC\n"
"+SEQ [] &seq\n"
@@ -249,7 +264,8 @@ ENGINE_TEST(AnchorSeqFlowWithRefMultiLine,
//-----------------------------------------------------------------------------
ENGINE_TEST(AnchorMapBlock,
("&map\n&key1 key1: &val1 val1\n&key2 key2: &val2 val2\n"),
"&map\n&key1 key1: &val1 val1\n&key2 key2: &val2 val2\n"
,
"+STR\n"
"+DOC\n"
"+MAP &map\n"
@@ -280,7 +296,8 @@ ENGINE_TEST(AnchorMapBlock,
}
ENGINE_TEST(AnchorMapBlockWithRef,
("&map\n&rkey1 key1: &rval1 val1\n*rkey1 : *rval1\n"),
"&map\n&rkey1 key1: &rval1 val1\n*rkey1 : *rval1\n"
,
"+STR\n"
"+DOC\n"
"+MAP &map\n"
@@ -312,7 +329,10 @@ ENGINE_TEST(AnchorMapBlockWithRef,
//-----------------------------------------------------------------------------
ENGINE_TEST(AnchorMapFlow,
("&map\n{&key1 key1: &val1 val1,&key2 key2: &val2 val2}", "&map {&key1 key1: &val1 val1,&key2 key2: &val2 val2}"),
"&map\n{&key1 key1: &val1 val1,&key2 key2: &val2 val2}"
,
"&map {&key1 key1: &val1 val1,&key2 key2: &val2 val2}"
,
"+STR\n"
"+DOC\n"
"+MAP {} &map\n"
@@ -343,7 +363,10 @@ ENGINE_TEST(AnchorMapFlow,
}
ENGINE_TEST(AnchorMapFlowMultiLine,
("&map\n{&key1 key1: &val1 val1,\n&key2 key2: &val2 val2\n}", "&map {&key1 key1: &val1 val1,&key2 key2: &val2 val2}"),
"&map\n{&key1 key1: &val1 val1,\n&key2 key2: &val2 val2\n}"
,
"&map {&key1 key1: &val1 val1,&key2 key2: &val2 val2}"
,
"+STR\n"
"+DOC\n"
"+MAP {} &map\n"
@@ -375,7 +398,10 @@ ENGINE_TEST(AnchorMapFlowMultiLine,
// WATCHOUT: see https://play.yaml.io/main/parser?input=Jm1hcAomcmtleTEgZm9vOiAmcnZhbDEgYmFyCipya2V5MSA6ICpydmFsMQ==
ENGINE_TEST(AnchorMapFlowWithRef,
("&map\n{&rkey1 key1: &rval1 val1,*rkey1 : *rval1}", "&map {&rkey1 key1: &rval1 val1,*rkey1 : *rval1}"),
"&map\n{&rkey1 key1: &rval1 val1,*rkey1 : *rval1}"
,
"&map {&rkey1 key1: &rval1 val1,*rkey1 : *rval1}"
,
"+STR\n"
"+DOC\n"
"+MAP {} &map\n"
@@ -405,7 +431,10 @@ ENGINE_TEST(AnchorMapFlowWithRef,
// WATCHOUT: see https://play.yaml.io/main/parser?input=Jm1hcAomcmtleTEgZm9vOiAmcnZhbDEgYmFyCipya2V5MSA6ICpydmFsMQ==
ENGINE_TEST(AnchorMapFlowWithRefMultiLine,
("&map\n{\n&rkey1 key1: &rval1 val1,\n*rkey1 : *rval1\n}", "&map {&rkey1 key1: &rval1 val1,*rkey1 : *rval1}"),
"&map\n{\n&rkey1 key1: &rval1 val1,\n*rkey1 : *rval1\n}"
,
"&map {&rkey1 key1: &rval1 val1,*rkey1 : *rval1}"
,
"+STR\n"
"+DOC\n"
"+MAP {} &map\n"
@@ -437,7 +466,8 @@ ENGINE_TEST(AnchorMapFlowWithRefMultiLine,
//-----------------------------------------------------------------------------
ENGINE_TEST(AnchorMapMapBlock,
("&map\n&mapkey map: &mapval\n &key1 key1: &val1 val1\n &key2 key2: &val2 val2\n"),
"&map\n&mapkey map: &mapval\n &key1 key1: &val1 val1\n &key2 key2: &val2 val2\n"
,
"+STR\n"
"+DOC\n"
"+MAP &map\n"
@@ -476,8 +506,10 @@ ENGINE_TEST(AnchorMapMapBlock,
}
ENGINE_TEST(AnchorMapMapFlow,
("&map\n{&mapkey map: &mapval {&key1 key1: &val1 val1,&key2 key2: &val2 val2,key3: val3},key4: val4}",
"&map {&mapkey map: &mapval {&key1 key1: &val1 val1,&key2 key2: &val2 val2,key3: val3},key4: val4}"),
"&map\n{&mapkey map: &mapval {&key1 key1: &val1 val1,&key2 key2: &val2 val2,key3: val3},key4: val4}"
,
"&map {&mapkey map: &mapval {&key1 key1: &val1 val1,&key2 key2: &val2 val2,key3: val3},key4: val4}"
,
"+STR\n"
"+DOC\n"
"+MAP {} &map\n"
@@ -530,28 +562,29 @@ ENGINE_TEST(AnchorMapMapFlow,
//-----------------------------------------------------------------------------
ENGINE_TEST(AnchorTagPlacement,
("- &a0 !b0 foo0: bar0\n"
"- &a1 !b1\n"
" foo1: bar1\n"
"- &a2\n"
" !b2 foo2: bar2\n"
"- &a3\n"
" !b3\n"
" foo3: bar3\n"
"- &a4\n"
"\n"
" !b4\n"
"\n"
" foo4: bar4\n",
"- !b0 &a0 foo0: bar0\n"
"- !b1 &a1\n"
" foo1: bar1\n"
"- &a2\n"
" !b2 foo2: bar2\n"
"- !b3 &a3\n"
" foo3: bar3\n"
"- !b4 &a4\n"
" foo4: bar4\n"),
"- &a0 !b0 foo0: bar0\n"
"- &a1 !b1\n"
" foo1: bar1\n"
"- &a2\n"
" !b2 foo2: bar2\n"
"- &a3\n"
" !b3\n"
" foo3: bar3\n"
"- &a4\n"
"\n"
" !b4\n"
"\n"
" foo4: bar4\n",
"- !b0 &a0 foo0: bar0\n"
"- !b1 &a1\n"
" foo1: bar1\n"
"- &a2\n"
" !b2 foo2: bar2\n"
"- !b3 &a3\n"
" foo3: bar3\n"
"- !b4 &a4\n"
" foo4: bar4\n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -623,52 +656,53 @@ ENGINE_TEST(AnchorTagPlacement,
ENGINE_TEST(AnchorMapMapSuckerPunch,
("!mymap &mymap\n"
"&fooanch !footag foo: &seq\n"
" &key1 key1: &val1 val1\n"
" &key2 key2: &val2 val2\n"
"!bartag &baranch bar: !a &map2\n"
" !b &key10 key10: !c &val10 val10\n"
" &key20 !b key20: &val20 !c val20\n"
" key10: 20\n"
"&bazanch !baztag baz: &map2 !a\n"
" &key10 !b key10: &val10 !c val10\n"
" !b &key20 key20: !c &val20 val20\n"
" key10: 20\n"
"brr: &map2\n"
" !a foo: bar\n"
"bra: &map2\n"
"\n"
"\n"
"\n"
" !a foo: bar\n"
"bre: &map2\n"
" !a\n"
" \n"
" \n"
" foo: bar\n"
"bru: &wtf\n"
" foo\n"
,
"!mymap &mymap\n"
"!footag &fooanch foo: &seq\n"
" &key1 key1: &val1 val1\n"
" &key2 key2: &val2 val2\n"
"!bartag &baranch bar: !a &map2\n"
" !b &key10 key10: !c &val10 val10\n"
" !b &key20 key20: !c &val20 val20\n"
" key10: 20\n"
"!baztag &bazanch baz: !a &map2\n"
" !b &key10 key10: !c &val10 val10\n"
" !b &key20 key20: !c &val20 val20\n"
" key10: 20\n"
"brr: &map2\n"
" !a foo: bar\n"
"bra: &map2\n"
" !a foo: bar\n"
"bre: !a &map2\n"
" foo: bar\n"
"bru: &wtf foo\n"),
"!mymap &mymap\n"
"&fooanch !footag foo: &seq\n"
" &key1 key1: &val1 val1\n"
" &key2 key2: &val2 val2\n"
"!bartag &baranch bar: !a &map2\n"
" !b &key10 key10: !c &val10 val10\n"
" &key20 !b key20: &val20 !c val20\n"
" key10: 20\n"
"&bazanch !baztag baz: &map2 !a\n"
" &key10 !b key10: &val10 !c val10\n"
" !b &key20 key20: !c &val20 val20\n"
" key10: 20\n"
"brr: &map2\n"
" !a foo: bar\n"
"bra: &map2\n"
"\n"
"\n"
"\n"
" !a foo: bar\n"
"bre: &map2\n"
" !a\n"
" \n"
" \n"
" foo: bar\n"
"bru: &wtf\n"
" foo\n"
,
"!mymap &mymap\n"
"!footag &fooanch foo: &seq\n"
" &key1 key1: &val1 val1\n"
" &key2 key2: &val2 val2\n"
"!bartag &baranch bar: !a &map2\n"
" !b &key10 key10: !c &val10 val10\n"
" !b &key20 key20: !c &val20 val20\n"
" key10: 20\n"
"!baztag &bazanch baz: !a &map2\n"
" !b &key10 key10: !c &val10 val10\n"
" !b &key20 key20: !c &val20 val20\n"
" key10: 20\n"
"brr: &map2\n"
" !a foo: bar\n"
"bra: &map2\n"
" !a foo: bar\n"
"bre: !a &map2\n"
" foo: bar\n"
"bru: &wtf foo\n"
,
"+STR\n"
"+DOC\n"
"+MAP &mymap <!mymap>\n"
@@ -820,50 +854,51 @@ ENGINE_TEST(AnchorMapMapSuckerPunch,
}
ENGINE_TEST(AnchorSeqMapSuckerPunch,
("&seq\n"
"- &key1 key1: &val1 val1\n"
" &key2 key2: &val2 val2\n"
"- !a &map2a\n"
" !b &key10 key10: &val10 val10\n"
" &key20 key20: &val20 val20\n"
" key10: 20\n"
"- &map2x !a\n"
" &key10 !b key10: &val10 val10\n"
" &key20 key20: &val20 val20\n"
" key10: 20\n"
"- &map2y\n"
" !a foo: bar\n"
"- &map2z\n"
"\n"
"\n"
"\n"
" !a foo: bar\n"
"- &map2u\n"
" !a\n"
" \n"
" \n"
" foo: bar\n"
"- &wtf\n"
" foo\n"
" ",
"&seq\n"
"- &key1 key1: &val1 val1\n"
" &key2 key2: &val2 val2\n"
"- !a &map2a\n"
" !b &key10 key10: &val10 val10\n"
" &key20 key20: &val20 val20\n"
" key10: 20\n"
"- !a &map2x\n"
" !b &key10 key10: &val10 val10\n"
" &key20 key20: &val20 val20\n"
" key10: 20\n"
"- &map2y\n"
" !a foo: bar\n"
"- &map2z\n"
" !a foo: bar\n"
"- !a &map2u\n"
" foo: bar\n"
"- &wtf foo\n"),
"&seq\n"
"- &key1 key1: &val1 val1\n"
" &key2 key2: &val2 val2\n"
"- !a &map2a\n"
" !b &key10 key10: &val10 val10\n"
" &key20 key20: &val20 val20\n"
" key10: 20\n"
"- &map2x !a\n"
" &key10 !b key10: &val10 val10\n"
" &key20 key20: &val20 val20\n"
" key10: 20\n"
"- &map2y\n"
" !a foo: bar\n"
"- &map2z\n"
"\n"
"\n"
"\n"
" !a foo: bar\n"
"- &map2u\n"
" !a\n"
" \n"
" \n"
" foo: bar\n"
"- &wtf\n"
" foo\n"
" ",
"&seq\n"
"- &key1 key1: &val1 val1\n"
" &key2 key2: &val2 val2\n"
"- !a &map2a\n"
" !b &key10 key10: &val10 val10\n"
" &key20 key20: &val20 val20\n"
" key10: 20\n"
"- !a &map2x\n"
" !b &key10 key10: &val10 val10\n"
" &key20 key20: &val20 val20\n"
" key10: 20\n"
"- &map2y\n"
" !a foo: bar\n"
"- &map2z\n"
" !a foo: bar\n"
"- !a &map2u\n"
" foo: bar\n"
"- &wtf foo\n"
,
"+STR\n"
"+DOC\n"
"+SEQ &seq\n"
@@ -988,9 +1023,11 @@ ENGINE_TEST(AnchorSeqMapSuckerPunch,
ENGINE_TEST(DocDoubleAnchorSeqMap,
(HAS_CONTAINER_KEYS,
"--- &docanchor\n"
"&anchor [seq, yeah]: foo\n"),
HAS_CONTAINER_KEYS
,
"--- &docanchor\n"
"&anchor [seq, yeah]: foo\n"
,
"+STR\n"
"+DOC ---\n"
"+MAP &docanchor\n"
@@ -1019,9 +1056,10 @@ ENGINE_TEST(DocDoubleAnchorSeqMap,
}
ENGINE_TEST(DoubleAnchorSeqMap,
(HAS_CONTAINER_KEYS,
"&docanchor\n"
"&anchor [seq, yeah]: foo\n"),
HAS_CONTAINER_KEYS,
"&docanchor\n"
"&anchor [seq, yeah]: foo\n"
,
"+STR\n"
"+DOC\n"
"+MAP &docanchor\n"
@@ -1050,9 +1088,10 @@ ENGINE_TEST(DoubleAnchorSeqMap,
}
ENGINE_TEST(DocDoubleAnchorKeyMap,
(HAS_CONTAINER_KEYS,
"--- &docanchor\n"
"&anchor {key: val}: foo\n"),
HAS_CONTAINER_KEYS,
"--- &docanchor\n"
"&anchor {key: val}: foo\n"
,
"+STR\n"
"+DOC ---\n"
"+MAP &docanchor\n"
@@ -1081,9 +1120,10 @@ ENGINE_TEST(DocDoubleAnchorKeyMap,
}
ENGINE_TEST(DoubleAnchorKeyMap,
(HAS_CONTAINER_KEYS,
"&docanchor\n"
"&anchor {key: val}: foo\n"),
HAS_CONTAINER_KEYS,
"&docanchor\n"
"&anchor {key: val}: foo\n"
,
"+STR\n"
"+DOC\n"
"+MAP &docanchor\n"

View File

@@ -11,17 +11,17 @@ namespace yml {
ENGINE_TEST(TagPlacementSeqFlow,
(""
"[\n"
"!tag ,\n"
"!tag 0,\n"
"!tag [],\n"
"!tag {},\n"
"]\n"
""
,
"[!tag ,!tag 0,!tag [],!tag {}]"
),
""
"[\n"
"!tag ,\n"
"!tag 0,\n"
"!tag [],\n"
"!tag {},\n"
"]\n"
""
,
"[!tag ,!tag 0,!tag [],!tag {}]"
,
""
"+STR\n"
"+DOC\n"
@@ -58,20 +58,20 @@ ENGINE_TEST(TagPlacementSeqFlow,
}
ENGINE_TEST(TagPlacementSeqBlock,
(""
"- !tag\n"
"- !tag 0\n"
"- !tag []\n"
"- !tag {}\n"
""
,
""
"- !tag \n"
"- !tag 0\n"
"- !tag []\n"
"- !tag {}\n"
""
),
""
"- !tag\n"
"- !tag 0\n"
"- !tag []\n"
"- !tag {}\n"
""
,
""
"- !tag \n"
"- !tag 0\n"
"- !tag []\n"
"- !tag {}\n"
""
,
""
"+STR\n"
"+DOC\n"
@@ -108,17 +108,17 @@ ENGINE_TEST(TagPlacementSeqBlock,
}
ENGINE_TEST(TagPlacementMapValFlow,
(""
"{\n"
"x: !tag,\n"
"a: !tag 0,\n"
"b: !tag [],\n"
"c: !tag {},\n"
"}\n"
""
,
"{x: !tag ,a: !tag 0,b: !tag [],c: !tag {}}"
),
""
"{\n"
"x: !tag,\n"
"a: !tag 0,\n"
"b: !tag [],\n"
"c: !tag {},\n"
"}\n"
""
,
"{x: !tag ,a: !tag 0,b: !tag [],c: !tag {}}"
,
""
"+STR\n"
"+DOC\n"
@@ -163,28 +163,28 @@ ENGINE_TEST(TagPlacementMapValFlow,
}
ENGINE_TEST(TagPlacementMapValBlock,
(""
"x: !tag\n"
"a: !tag 0\n"
"b: !tag []\n"
"c: !tag {}\n"
"d: !tag\n"
" e: !tag\n"
"f: !tag\n"
" - !tag g\n"
""
,
""
"x: !tag \n"
"a: !tag 0\n"
"b: !tag []\n"
"c: !tag {}\n"
"d: !tag\n"
" e: !tag \n"
"f: !tag\n"
" - !tag g\n"
""
),
""
"x: !tag\n"
"a: !tag 0\n"
"b: !tag []\n"
"c: !tag {}\n"
"d: !tag\n"
" e: !tag\n"
"f: !tag\n"
" - !tag g\n"
""
,
""
"x: !tag \n"
"a: !tag 0\n"
"b: !tag []\n"
"c: !tag {}\n"
"d: !tag\n"
" e: !tag \n"
"f: !tag\n"
" - !tag g\n"
""
,
""
"+STR\n"
"+DOC\n"
@@ -253,17 +253,17 @@ ENGINE_TEST(TagPlacementMapValBlock,
}
ENGINE_TEST(TagPlacementMapKeyFlow,
(HAS_CONTAINER_KEYS, Location(34,4,7),
""
"!mtag {\n"
"!tag : x\n,"
"!tag a: x\n,"
"!tag []: x\n,"
"!tag {}: x\n,"
"!tag :\n,"
"}\n"
""
),
HAS_CONTAINER_KEYS, Location(34,4,7),
""
"!mtag {\n"
"!tag : x\n,"
"!tag a: x\n,"
"!tag []: x\n,"
"!tag {}: x\n,"
"!tag :\n,"
"}\n"
""
,
""
"+STR\n"
"+DOC\n"
@@ -315,16 +315,16 @@ ENGINE_TEST(TagPlacementMapKeyFlow,
}
ENGINE_TEST(TagPlacementMapKeyBlock,
(HAS_CONTAINER_KEYS, Location(30,4,6),
""
"!mtag\n"
"!tag : x\n"
"!tag a: x\n"
"!tag []: x\n"
"!tag {}: x\n"
"!tag :\n"
""
),
HAS_CONTAINER_KEYS, Location(30,4,6),
""
"!mtag\n"
"!tag : x\n"
"!tag a: x\n"
"!tag []: x\n"
"!tag {}: x\n"
"!tag :\n"
""
,
""
"+STR\n"
"+DOC\n"
@@ -376,15 +376,15 @@ ENGINE_TEST(TagPlacementMapKeyBlock,
}
ENGINE_TEST(TagPlacementMapValBlock2_0,
(""
"a:\n"
" : \n"
""
,
""
"a:\n"
" : \n"
),
""
"a:\n"
" : \n"
""
,
""
"a:\n"
" : \n"
,
""
"+STR\n"
"+DOC\n"
@@ -412,12 +412,12 @@ ENGINE_TEST(TagPlacementMapValBlock2_0,
}
ENGINE_TEST(TagPlacementMapValBlock2_1,
(""
"a:\n"
" : \n"
"b: c\n"
""
),
""
"a:\n"
" : \n"
"b: c\n"
""
,
""
"+STR\n"
"+DOC\n"
@@ -450,22 +450,22 @@ ENGINE_TEST(TagPlacementMapValBlock2_1,
}
ENGINE_TEST(TagPlacementMapValBlock2,
(""
"!mtag\n"
"!tag0 : !tag1\n"
" !tag2 : !tag3\n"
"a:\n"
" : \n"
""
,
""
"!mtag\n"
"!tag0 : !tag1\n"
" !tag2 : !tag3 \n"
"a:\n"
" : \n"
""
),
""
"!mtag\n"
"!tag0 : !tag1\n"
" !tag2 : !tag3\n"
"a:\n"
" : \n"
""
,
""
"!mtag\n"
"!tag0 : !tag1\n"
" !tag2 : !tag3 \n"
"a:\n"
" : \n"
""
,
""
"+STR\n"
"+DOC\n"
@@ -509,27 +509,27 @@ ENGINE_TEST(TagPlacementMapValBlock2,
}
ENGINE_TEST(TagPlacementMapComplex,
(HAS_CONTAINER_KEYS, Location(18,3,5),
""
"!mtag\n"
"? !tag0\n"
" !a : !b\n"
": !tag1\n"
" !a : !b\n"
HAS_CONTAINER_KEYS, Location(18,3,5),
""
"!mtag\n"
"? !tag0\n"
" !a : !b\n"
": !tag1\n"
" !a : !b\n"
"? !tag2\n"
" !a 1: !b 2\n"
": !tag3\n"
" !a : !b\n"
"? !tag2\n"
" !a 1: !b 2\n"
": !tag3\n"
" !a : !b\n"
"? !tag4\n"
" - !a 1\n"
" - !b 2\n"
": !tag5\n"
" !a : !b\n"
"? !tag6\n"
""
),
"? !tag4\n"
" - !a 1\n"
" - !b 2\n"
": !tag5\n"
" !a : !b\n"
"? !tag6\n"
""
,
""
"+STR\n"
"+DOC\n"
@@ -630,7 +630,8 @@ ENGINE_TEST(TagPlacementMapComplex,
//-----------------------------------------------------------------------------
ENGINE_TEST(TagBlockSeq,
("- !light fluorescent\n- notag\n"),
"- !light fluorescent\n- notag\n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -653,7 +654,8 @@ ENGINE_TEST(TagBlockSeq,
}
ENGINE_TEST(TagFlowSeq,
("[!light fluorescent,notag]"),
"[!light fluorescent,notag]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -676,17 +678,19 @@ ENGINE_TEST(TagFlowSeq,
}
ENGINE_TEST(DirectiveAndTag,
("%YAML 1.2\n"
"---\n"
"!light fluorescent\n"
"...\n"
"%TAG !m! !my-\n"
"---\n"
"!m!light green\n",
"--- !light fluorescent\n"
"...\n"
"%TAG !m! !my-\n"
"--- !m!light green\n"),
"%YAML 1.2\n"
"---\n"
"!light fluorescent\n"
"...\n"
"%TAG !m! !my-\n"
"---\n"
"!m!light green\n"
,
"--- !light fluorescent\n"
"...\n"
"%TAG !m! !my-\n"
"--- !m!light green\n"
,
"+STR\n"
"+DOC ---\n"
"=VAL <!light> :fluorescent\n"
@@ -726,7 +730,10 @@ ENGINE_TEST_ERRLOC(TagTestSuiteU99R_1, Location(2,1),
"- !str, xxx\n")
ENGINE_TEST(TagTestSuiteU99R_2,
("[!!str, xxx]", "[!!str ,xxx]"),
"[!!str, xxx]"
,
"[!!str ,xxx]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -749,7 +756,8 @@ ENGINE_TEST(TagTestSuiteU99R_2,
}
ENGINE_TEST(TagTestSuiteU99R_2_1,
("[!str, xxx]","[!str ,xxx]"),
"[!str, xxx]","[!str ,xxx]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -772,7 +780,10 @@ ENGINE_TEST(TagTestSuiteU99R_2_1,
}
ENGINE_TEST(TagTestSuiteU99R_3,
("{!!str, xxx}", "{!!str : ,xxx: }"),
"{!!str, xxx}"
,
"{!!str : ,xxx: }"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -799,7 +810,10 @@ ENGINE_TEST(TagTestSuiteU99R_3,
}
ENGINE_TEST(TagTestSuiteU99R_3_1,
("{!str, xxx}", "{!str : ,xxx: }"),
"{!str, xxx}"
,
"{!str : ,xxx: }"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -826,7 +840,10 @@ ENGINE_TEST(TagTestSuiteU99R_3_1,
}
ENGINE_TEST(TagTestSuiteWZ62_0_0_0,
("{foo: !!str , !!str : bar}", "{foo: !!str ,!!str : bar}"),
"{foo: !!str , !!str : bar}"
,
"{foo: !!str ,!!str : bar}"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -854,7 +871,10 @@ ENGINE_TEST(TagTestSuiteWZ62_0_0_0,
}
ENGINE_TEST(TagTestSuiteWZ62_0_0_1,
("foo: !!str\n!!str : bar\n", "foo: !!str \n!!str : bar\n"),
"foo: !!str\n!!str : bar\n"
,
"foo: !!str \n!!str : bar\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -882,7 +902,10 @@ ENGINE_TEST(TagTestSuiteWZ62_0_0_1,
}
ENGINE_TEST(TagTestSuiteWZ62_0_1_0,
("{foo: !str , !str : bar}", "{foo: !str ,!str : bar}"),
"{foo: !str , !str : bar}"
,
"{foo: !str ,!str : bar}"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -910,7 +933,10 @@ ENGINE_TEST(TagTestSuiteWZ62_0_1_0,
}
ENGINE_TEST(TagTestSuiteWZ62_0_1_1,
("foo: !str\n!str : bar\n", "foo: !str \n!str : bar\n"),
"foo: !str\n!str : bar\n"
,
"foo: !str \n!str : bar\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -938,7 +964,10 @@ ENGINE_TEST(TagTestSuiteWZ62_0_1_1,
}
ENGINE_TEST(TagTestSuiteWZ62_1_0_0,
("{foo: !!str, !!str: bar}", "{foo: !!str ,!!str: bar: }"),
"{foo: !!str, !!str: bar}"
,
"{foo: !!str ,!!str: bar: }"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -966,7 +995,10 @@ ENGINE_TEST(TagTestSuiteWZ62_1_0_0,
}
ENGINE_TEST(TagTestSuiteWZ62_1_0_1,
("foo: !!str\n!!str: bar:\n", "foo: !!str \n!!str: bar: \n"),
"foo: !!str\n!!str: bar:\n"
,
"foo: !!str \n!!str: bar: \n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -994,7 +1026,10 @@ ENGINE_TEST(TagTestSuiteWZ62_1_0_1,
}
ENGINE_TEST(TagTestSuiteWZ62_1_1_0,
("{foo: !str, !str: bar}", "{foo: !str ,!str: bar: }"),
"{foo: !str, !str: bar}"
,
"{foo: !str ,!str: bar: }"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -1022,7 +1057,10 @@ ENGINE_TEST(TagTestSuiteWZ62_1_1_0,
}
ENGINE_TEST(TagTestSuiteWZ62_1_1_1,
("foo: !str\n!str: bar:\n", "foo: !str \n!str: bar: \n"),
"foo: !str\n!str: bar:\n"
,
"foo: !str \n!str: bar: \n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -1058,9 +1096,10 @@ ENGINE_TEST_ERRLOC(TagTestSuiteLHL4_1, Location(3,1),
"!!invalid{}tag scalar\n")
ENGINE_TEST(TagTestSuiteUGM3,
("--- !<tag:clarkevans.com,2002:invoice>\n"
"--- !<tag:clarkevans.com,2002:invoice>\n"
"invoice: 34843\n"
"date: 2001-01-23\n"),
"date: 2001-01-23\n"
,
"+STR\n"
"+DOC ---\n"
"+MAP <tag:clarkevans.com,2002:invoice>\n"
@@ -1087,7 +1126,10 @@ ENGINE_TEST(TagTestSuiteUGM3,
}
ENGINE_TEST(TagTestSuiteUKK6_02_0,
("!", "! \n"),
"!"
,
"! \n"
,
"+STR\n"
"+DOC\n"
"=VAL <!> :\n"
@@ -1103,10 +1145,11 @@ ENGINE_TEST(TagTestSuiteUKK6_02_0,
}
ENGINE_TEST(TagTestSuite6WLZ_0,
("--- !foo \"bar\"\n"
"...\n"
"%TAG ! tag:example.com,2000:app/\n"
"--- !foo \"bar\"\n"),
"--- !foo \"bar\"\n"
"...\n"
"%TAG ! tag:example.com,2000:app/\n"
"--- !foo \"bar\"\n"
,
"+STR\n"
"+DOC ---\n"
"=VAL <!foo> \"bar\n"
@@ -1130,10 +1173,11 @@ ENGINE_TEST(TagTestSuite6WLZ_0,
}
ENGINE_TEST(TagTestSuite6WLZ_1,
("--- !foo \"bar\"\n"
"...\n"
"%TAG ! tag:example.com,2000:app/\n"
"--- !<tag:example.com,2000:app/foo> \"bar\"\n"),
"--- !foo \"bar\"\n"
"...\n"
"%TAG ! tag:example.com,2000:app/\n"
"--- !<tag:example.com,2000:app/foo> \"bar\"\n"
,
"+STR\n"
"+DOC ---\n"
"=VAL <!foo> \"bar\n"
@@ -1176,9 +1220,11 @@ ENGINE_TEST_ERR(DirectiveTestSuite9HCY,
"!foo \"bar\"\n")
ENGINE_TEST(DirectiveTestSuiteMUS6,
("%YAM 1.1\n"
"---\n",
"---\n"),
"%YAM 1.1\n"
"---\n"
,
"---\n"
,
"+STR\n"
"+DOC ---\n"
"=VAL :\n"
@@ -1194,19 +1240,21 @@ ENGINE_TEST(DirectiveTestSuiteMUS6,
}
ENGINE_TEST(DirectiveMultipleYAML_W4TN,
(""
"%YAML 1.2\n"
"---\n"
"foo\n"
"...\n"
"%YAML 1.2\n"
"---\n"
"# Empty\n"
"...\n"
"",
"--- foo\n"
"---\n"
""),
""
"%YAML 1.2\n"
"---\n"
"foo\n"
"...\n"
"%YAML 1.2\n"
"---\n"
"# Empty\n"
"...\n"
""
,
"--- foo\n"
"---\n"
""
,
"+STR\n"
"+DOC ---\n"
"=VAL :foo\n"
@@ -1284,7 +1332,10 @@ ENGINE_TEST_ERR(DirectiveTooMany,
//-----------------------------------------------------------------------------
ENGINE_TEST(TagEmptySeq0,
("!!seq []\n", "!!seq []"),
"!!seq []\n"
,
"!!seq []"
,
"+STR\n+DOC\n+SEQ [] <tag:yaml.org,2002:seq>\n-SEQ\n-DOC\n-STR\n")
{
___(ps.begin_stream());
@@ -1297,9 +1348,10 @@ ENGINE_TEST(TagEmptySeq0,
}
ENGINE_TEST(TagEmptySeq1,
(""
"- !!seq []\n"
""),
""
"- !!seq []\n"
""
,
"+STR\n+DOC\n+SEQ\n+SEQ [] <tag:yaml.org,2002:seq>\n-SEQ\n-SEQ\n-DOC\n-STR\n")
{
___(ps.begin_stream());
@@ -1314,10 +1366,11 @@ ENGINE_TEST(TagEmptySeq1,
}
ENGINE_TEST(TagEmptySeq2,
(""
"!!seq\n"
"- !!seq []\n"
""),
""
"!!seq\n"
"- !!seq []\n"
""
,
"+STR\n+DOC\n+SEQ <tag:yaml.org,2002:seq>\n+SEQ [] <tag:yaml.org,2002:seq>\n-SEQ\n-SEQ\n-DOC\n-STR\n")
{
___(ps.begin_stream());
@@ -1336,7 +1389,10 @@ ENGINE_TEST(TagEmptySeq2,
//-----------------------------------------------------------------------------
ENGINE_TEST(TagEmptyMap0,
("!!map {}\n", "!!map {}"),
"!!map {}\n"
,
"!!map {}"
,
"+STR\n+DOC\n+MAP {} <tag:yaml.org,2002:map>\n-MAP\n-DOC\n-STR\n")
{
___(ps.begin_stream());
@@ -1349,9 +1405,10 @@ ENGINE_TEST(TagEmptyMap0,
}
ENGINE_TEST(TagEmptyMap1,
(""
"- !!map {}\n"
""),
""
"- !!map {}\n"
""
,
"+STR\n+DOC\n+SEQ\n+MAP {} <tag:yaml.org,2002:map>\n-MAP\n-SEQ\n-DOC\n-STR\n")
{
___(ps.begin_stream());
@@ -1366,10 +1423,11 @@ ENGINE_TEST(TagEmptyMap1,
}
ENGINE_TEST(TagEmptyMap2,
(""
"!!seq\n"
"- !!map {}\n"
""),
""
"!!seq\n"
"- !!map {}\n"
""
,
"+STR\n+DOC\n+SEQ <tag:yaml.org,2002:seq>\n+MAP {} <tag:yaml.org,2002:map>\n-MAP\n-SEQ\n-DOC\n-STR\n")
{
___(ps.begin_stream());
@@ -1388,20 +1446,22 @@ ENGINE_TEST(TagEmptyMap2,
//-----------------------------------------------------------------------------
ENGINE_TEST(TagYs0,
(""
"!yamlscript/v0/bare\n"
"--- !code\n"
"--- !data\n"
"--- !code\n"
"--- !data\n"
"",
""
"--- !yamlscript/v0/bare \n"
"--- !code \n"
"--- !data \n"
"--- !code \n"
"--- !data \n"
""),
""
"!yamlscript/v0/bare\n"
"--- !code\n"
"--- !data\n"
"--- !code\n"
"--- !data\n"
""
,
""
"--- !yamlscript/v0/bare \n"
"--- !code \n"
"--- !data \n"
"--- !code \n"
"--- !data \n"
""
,
"+STR\n"
"+DOC\n"
"=VAL <!yamlscript/v0/bare> :\n"
@@ -1445,15 +1505,17 @@ ENGINE_TEST(TagYs0,
}
ENGINE_TEST(TagYs1,
(""
"!yamlscript/v0/bare\n"
"--- !code\n"
"42\n"
"",
""
"--- !yamlscript/v0/bare \n"
"--- !code 42\n"
""),
""
"!yamlscript/v0/bare\n"
"--- !code\n"
"42\n"
""
,
""
"--- !yamlscript/v0/bare \n"
"--- !code 42\n"
""
,
"+STR\n"
"+DOC\n"
"=VAL <!yamlscript/v0/bare> :\n"
@@ -1475,7 +1537,6 @@ ENGINE_TEST(TagYs1,
___(ps.end_stream());
}
} // namespace yml
} // namespace c4

View File

@@ -9,10 +9,11 @@ namespace yml {
//-----------------------------------------------------------------------------
ENGINE_TEST(Qmrk0,
(HAS_CONTAINER_KEYS, Location(41,3,19),
"\n"
"a simple key: a value\n"
"? an explicit key: another value\n"),
HAS_CONTAINER_KEYS, Location(41,3,19),
"\n"
"a simple key: a value\n"
"? an explicit key: another value\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -44,10 +45,12 @@ ENGINE_TEST(Qmrk0,
}
ENGINE_TEST(Qmrk1_0,
("? an explicit key\n"
"a simple key: a value\n",
"an explicit key: \n"
"a simple key: a value\n"),
"? an explicit key\n"
"a simple key: a value\n"
,
"an explicit key: \n"
"a simple key: a value\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -73,10 +76,11 @@ ENGINE_TEST(Qmrk1_0,
}
ENGINE_TEST(Qmrk1_1,
(HAS_CONTAINER_KEYS, Location(19,2,19),
"\n"
"? an explicit key: another value\n"
"a simple key: a value\n"),
HAS_CONTAINER_KEYS, Location(19,2,19),
"\n"
"? an explicit key: another value\n"
"a simple key: a value\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -108,12 +112,13 @@ ENGINE_TEST(Qmrk1_1,
}
ENGINE_TEST(Qmrk1_2,
(HAS_CONTAINER_KEYS, Location(25,2,21),
"map:\n"
" ? an explicit key: another value\n"
" a simple key: a value\n"
"? an explicit key deindented: its value\n"
"? more: siblings\n"),
HAS_CONTAINER_KEYS, Location(25,2,21),
"map:\n"
" ? an explicit key: another value\n"
" a simple key: a value\n"
"? an explicit key deindented: its value\n"
"? more: siblings\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -173,13 +178,14 @@ ENGINE_TEST(Qmrk1_2,
}
ENGINE_TEST(Qmrk2_0,
("? an explicit key\n"
"...\n"
"? another explicit key\n",
"---\n"
"an explicit key: \n"
"---\n"
"another explicit key: \n"),
"? an explicit key\n"
"...\n"
"? another explicit key\n",
"---\n"
"an explicit key: \n"
"---\n"
"another explicit key: \n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -212,13 +218,15 @@ ENGINE_TEST(Qmrk2_0,
}
ENGINE_TEST(Qmrk2_1,
("? an explicit key\n"
"---\n"
"? another explicit key\n",
"---\n"
"an explicit key: \n"
"---\n"
"another explicit key: \n"),
"? an explicit key\n"
"---\n"
"? another explicit key\n"
,
"---\n"
"an explicit key: \n"
"---\n"
"another explicit key: \n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -251,8 +259,10 @@ ENGINE_TEST(Qmrk2_1,
}
ENGINE_TEST(Qmrk3,
("{ ? an explicit key, ? foo,? bar,?baz:,?bat}",
"{an explicit key: ,foo: ,bar: ,?baz: ,?bat: }"),
"{ ? an explicit key, ? foo,? bar,?baz:,?bat}"
,
"{an explicit key: ,foo: ,bar: ,?baz: ,?bat: }"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -293,8 +303,10 @@ ENGINE_TEST(Qmrk3,
}
ENGINE_TEST(Qmrk4_0,
("[?baz:,]",
"[{?baz: }]"),
"[?baz:,]"
,
"[{?baz: }]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -319,8 +331,10 @@ ENGINE_TEST(Qmrk4_0,
}
ENGINE_TEST(Qmrk4,
("[ ? an explicit key, ? foo,? bar,?baz:,?bat]",
"[{an explicit key: },{foo: },{bar: },{?baz: },?bat]"),
"[ ? an explicit key, ? foo,? bar,?baz:,?bat]"
,
"[{an explicit key: },{foo: },{bar: },{?baz: },?bat]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -375,10 +389,11 @@ ENGINE_TEST(Qmrk4,
}
ENGINE_TEST(Qmrk5,
(HAS_CONTAINER_KEYS, Location(4,1,5),
"? a: b\n"
"?\n"
"?\n"),
HAS_CONTAINER_KEYS, Location(4,1,5),
"? a: b\n"
"?\n"
"?\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -416,11 +431,12 @@ ENGINE_TEST(Qmrk5,
ENGINE_TEST(Qmrk6,
(HAS_CONTAINER_KEYS, Location(21,2,21),
"\n"
"- ? an explicit key: another value\n"
" a simple key: a value\n"
"- ? another explicit key: its value\n"),
HAS_CONTAINER_KEYS, Location(21,2,21),
"\n"
"- ? an explicit key: another value\n"
" a simple key: a value\n"
"- ? another explicit key: its value\n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -471,11 +487,12 @@ ENGINE_TEST(Qmrk6,
}
ENGINE_TEST(Qmrk7,
(HAS_CONTAINER_KEYS, Location(5,2,5),
"\n"
"- ? : x\n"
"- ? : \n"
"- ? :\n"),
HAS_CONTAINER_KEYS, Location(5,2,5),
"\n"
"- ? : x\n"
"- ? : \n"
"- ? :\n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -536,11 +553,12 @@ ENGINE_TEST(Qmrk7,
}
ENGINE_TEST(QmrkWithTags,
(HAS_CONTAINER_KEYS, Location(18,3,6),
"a1: b1\n"
"? !at\n"
" !bt : b2\n"
": c3\n"),
HAS_CONTAINER_KEYS, Location(18,3,6),
"a1: b1\n"
"? !at\n"
" !bt : b2\n"
": c3\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -575,12 +593,14 @@ ENGINE_TEST(QmrkWithTags,
ENGINE_TEST(QmrkGithub524_0,
("? outer\n"
": inner1: 1\n"
" inner2: 2\n",
"outer:\n"
" inner1: 1\n"
" inner2: 2\n"),
"? outer\n"
": inner1: 1\n"
" inner2: 2\n"
,
"outer:\n"
" inner1: 1\n"
" inner2: 2\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -612,13 +632,14 @@ ENGINE_TEST(QmrkGithub524_0,
}
ENGINE_TEST(QmrkGithub524_1,
("? outer\n"
": inner1: 1\n"
"inner2: 2\n"
,
"outer:\n"
" inner1: 1\n"
"inner2: 2\n"),
"? outer\n"
": inner1: 1\n"
"inner2: 2\n"
,
"outer:\n"
" inner1: 1\n"
"inner2: 2\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -654,7 +675,10 @@ ENGINE_TEST(QmrkGithub524_1,
//-----------------------------------------------------------------------------
ENGINE_TEST(QmrkFlow0,
("{ ? }", "{: }"),
"{ ? }"
,
"{: }"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -675,7 +699,10 @@ ENGINE_TEST(QmrkFlow0,
}
ENGINE_TEST(QmrkFlow1,
("{ ? , }", "{: }"),
"{ ? , }"
,
"{: }"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -696,7 +723,10 @@ ENGINE_TEST(QmrkFlow1,
}
ENGINE_TEST(QmrkFlow1Anch,
("{ ? &anch , }", "{&anch : }"),
"{ ? &anch , }"
,
"{&anch : }"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -718,7 +748,10 @@ ENGINE_TEST(QmrkFlow1Anch,
}
ENGINE_TEST(QmrkFlow1Tag,
("{ ? !tag , }", "{!tag : }"),
"{ ? !tag , }"
,
"{!tag : }"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -740,7 +773,10 @@ ENGINE_TEST(QmrkFlow1Tag,
}
ENGINE_TEST(QmrkFlow1Squo,
("{ ? 'squo', }", "{'squo': }"),
"{ ? 'squo', }"
,
"{'squo': }"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -761,7 +797,10 @@ ENGINE_TEST(QmrkFlow1Squo,
}
ENGINE_TEST(QmrkFlow1AnchSquo,
("{ ? &anch 'squo', }", "{&anch 'squo': }"),
"{ ? &anch 'squo', }"
,
"{&anch 'squo': }"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -783,7 +822,10 @@ ENGINE_TEST(QmrkFlow1AnchSquo,
}
ENGINE_TEST(QmrkFlow1TagSquo,
("{ ? !tag 'squo', }", "{!tag 'squo': }"),
"{ ? !tag 'squo', }"
,
"{!tag 'squo': }"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -805,7 +847,10 @@ ENGINE_TEST(QmrkFlow1TagSquo,
}
ENGINE_TEST(QmrkFlow1Dquo,
("{ ? \"dquo\", }", "{\"dquo\": }"),
"{ ? \"dquo\", }"
,
"{\"dquo\": }"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -826,7 +871,10 @@ ENGINE_TEST(QmrkFlow1Dquo,
}
ENGINE_TEST(QmrkFlow1AnchDquo,
("{ ? &anch \"dquo\", }", "{&anch \"dquo\": }"),
"{ ? &anch \"dquo\", }"
,
"{&anch \"dquo\": }"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -848,7 +896,10 @@ ENGINE_TEST(QmrkFlow1AnchDquo,
}
ENGINE_TEST(QmrkFlow1TagDquo,
("{ ? !tag \"dquo\", }", "{!tag \"dquo\": }"),
"{ ? !tag \"dquo\", }"
,
"{!tag \"dquo\": }"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -870,7 +921,10 @@ ENGINE_TEST(QmrkFlow1TagDquo,
}
ENGINE_TEST(QmrkFlow1Ref,
("{ ? *ref , }", "{*ref : }"),
"{ ? *ref , }"
,
"{*ref : }"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -891,8 +945,11 @@ ENGINE_TEST(QmrkFlow1Ref,
}
ENGINE_TEST(QmrkFlow1Seq,
(HAS_CONTAINER_KEYS,
"{ ? [a, b]: c , }", "{? [a, b] : c}"),
HAS_CONTAINER_KEYS,
"{ ? [a, b]: c , }"
,
"{? [a, b] : c}"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -919,8 +976,11 @@ ENGINE_TEST(QmrkFlow1Seq,
}
ENGINE_TEST(QmrkFlow1SeqAnchor,
(HAS_CONTAINER_KEYS,
"{ ? &anchor [a, b]: c , }", "{? &anchor [a, b] : c}"),
HAS_CONTAINER_KEYS,
"{ ? &anchor [a, b]: c , }"
,
"{? &anchor [a, b] : c}"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -948,8 +1008,11 @@ ENGINE_TEST(QmrkFlow1SeqAnchor,
}
ENGINE_TEST(QmrkFlow1SeqTag,
(HAS_CONTAINER_KEYS,
"{ ? !tag [a, b]: c , }", "{? !tag [a, b] : c}"),
HAS_CONTAINER_KEYS,
"{ ? !tag [a, b]: c , }"
,
"{? !tag [a, b] : c}"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -977,8 +1040,11 @@ ENGINE_TEST(QmrkFlow1SeqTag,
}
ENGINE_TEST(QmrkFlow1Map,
(HAS_CONTAINER_KEYS,
"{ ? {a: b}: c , }", "{? {a: b} : c}"),
HAS_CONTAINER_KEYS,
"{ ? {a: b}: c , }"
,
"{? {a: b} : c}"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -1005,8 +1071,11 @@ ENGINE_TEST(QmrkFlow1Map,
}
ENGINE_TEST(QmrkFlow1MapAnchor,
(HAS_CONTAINER_KEYS,
"{ ? &anchor {a: b}: c , }", "{? &anchor {a: b} : c}"),
HAS_CONTAINER_KEYS,
"{ ? &anchor {a: b}: c , }"
,
"{? &anchor {a: b} : c}"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -1034,8 +1103,11 @@ ENGINE_TEST(QmrkFlow1MapAnchor,
}
ENGINE_TEST(QmrkFlow1MapTag,
(HAS_CONTAINER_KEYS,
"{ ? !tag {a: b}: c , }", "{? !tag {a: b} : c}"),
HAS_CONTAINER_KEYS,
"{ ? !tag {a: b}: c , }"
,
"{? !tag {a: b} : c}"
,
"+STR\n"
"+DOC\n"
"+MAP {}\n"
@@ -1064,8 +1136,9 @@ ENGINE_TEST(QmrkFlow1MapTag,
#ifdef TODO_FIXME // this is the only failing suite test
ENGINE_TEST(QmrkTestSuiteM2N8_01_0,
(HAS_CONTAINER_KEYS,
"? []: x"),
HAS_CONTAINER_KEYS,
"? []: x"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -1095,8 +1168,9 @@ ENGINE_TEST(QmrkTestSuiteM2N8_01_0,
}
ENGINE_TEST(QmrkTestSuiteM2N8_01_1,
(HAS_CONTAINER_KEYS,
"? {}: x"),
HAS_CONTAINER_KEYS,
"? {}: x"
,
"+STR\n"
"+DOC\n"
"+MAP\n"

View File

@@ -10,7 +10,8 @@ namespace yml {
//-----------------------------------------------------------------------------
ENGINE_TEST(SeqIMap0Ref,
("[val0,val1,{key: val2},wtf]"),
"[val0,val1,{key: val2},wtf]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -44,7 +45,10 @@ ENGINE_TEST(SeqIMap0Ref,
}
ENGINE_TEST(SeqIMap1,
("[val0,val1,key: val2,wtf]", "[val0,val1,{key: val2},wtf]"),
"[val0,val1,key: val2,wtf]"
,
"[val0,val1,{key: val2},wtf]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -82,7 +86,10 @@ ENGINE_TEST(SeqIMap1,
}
ENGINE_TEST(SeqIMap2,
("[val0,val1,key: [foo: bar],wtf]", "[val0,val1,{key: [{foo: bar}]},wtf]"),
"[val0,val1,key: [foo: bar],wtf]"
,
"[val0,val1,{key: [{foo: bar}]},wtf]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -127,8 +134,10 @@ ENGINE_TEST(SeqIMap2,
ENGINE_TEST(SeqIMap2Nested,
("[val: [0: [1: [2: [3: [4: [5: [6: 7]]]]]]], :]",
"[{val: [{0: [{1: [{2: [{3: [{4: [{5: [{6: 7}]}]}]}]}]}]}]},{: }]"),
"[val: [0: [1: [2: [3: [4: [5: [6: 7]]]]]]], :]"
,
"[{val: [{0: [{1: [{2: [{3: [{4: [{5: [{6: 7}]}]}]}]}]}]}]},{: }]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -233,7 +242,10 @@ ENGINE_TEST(SeqIMap2Nested,
ENGINE_TEST(SeqIMap3EmptyKey,
("[val0, : wtf]", "[val0,{: wtf}]"),
"[val0, : wtf]"
,
"[val0,{: wtf}]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -261,7 +273,10 @@ ENGINE_TEST(SeqIMap3EmptyKey,
}
ENGINE_TEST(SeqIMap3EmptyVal,
("[val0, wtf: ]", "[val0,{wtf: }]"),
"[val0, wtf: ]"
,
"[val0,{wtf: }]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -289,7 +304,10 @@ ENGINE_TEST(SeqIMap3EmptyVal,
}
ENGINE_TEST(SeqIMap3EmptyKeyVal,
("[val0, : ]", "[val0,{: }]"),
"[val0, : ]"
,
"[val0,{: }]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -317,7 +335,10 @@ ENGINE_TEST(SeqIMap3EmptyKeyVal,
}
ENGINE_TEST(SeqIMap3EmptyKeyValNested,
("[val0: val1, : ]", "[{val0: val1},{: }]"),
"[val0: val1, : ]"
,
"[{val0: val1},{: }]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -351,7 +372,10 @@ ENGINE_TEST(SeqIMap3EmptyKeyValNested,
}
ENGINE_TEST(SeqIMap3EmptyKeyValNested2,
("[val0: [val1: val2], : ]", "[{val0: [{val1: val2}]},{: }]"),
"[val0: [val1: val2], : ]"
,
"[{val0: [{val1: val2}]},{: }]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -395,7 +419,8 @@ ENGINE_TEST(SeqIMap3EmptyKeyValNested2,
}
ENGINE_TEST(SeqIMap4Ref,
("[val0,val1,[rat,rot],wtf]"),
"[val0,val1,[rat,rot],wtf]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -430,7 +455,12 @@ ENGINE_TEST(SeqIMap4Ref,
}
ENGINE_TEST(SeqIMap4,
(HAS_CONTAINER_KEYS, Location(20,1,21), "[val0,val1,[rat,rot]: [foo: bar],wtf]", "[val0,val1,{[rat,rot]: [{foo: bar}]},wtf]"),
HAS_CONTAINER_KEYS, Location(20,1,21)
,
"[val0,val1,[rat,rot]: [foo: bar],wtf]"
,
"[val0,val1,{[rat,rot]: [{foo: bar}]},wtf]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -481,7 +511,11 @@ ENGINE_TEST(SeqIMap4,
}
ENGINE_TEST(SeqIMap4_actually,
(HAS_CONTAINER_KEYS, Location(20,1,21), "[val0,val1,[rat,rot]: [foo: bar],wtf]", "[val0,val1,{[rat,rot]: [{foo: bar}]},wtf]"),
HAS_CONTAINER_KEYS, Location(20,1,21),
"[val0,val1,[rat,rot]: [foo: bar],wtf]"
,
"[val0,val1,{[rat,rot]: [{foo: bar}]},wtf]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -535,7 +569,10 @@ ENGINE_TEST(SeqIMap4_actually,
//-----------------------------------------------------------------------------
ENGINE_TEST(SeqIMap5Squo,
("[a: &anchor 'b']", "[{a: &anchor 'b'}]"),
"[a: &anchor 'b']"
,
"[{a: &anchor 'b'}]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -561,7 +598,10 @@ ENGINE_TEST(SeqIMap5Squo,
}
ENGINE_TEST(SeqIMap5Dquo,
("[a: &anchor \"b\"]", "[{a: &anchor \"b\"}]"),
"[a: &anchor \"b\"]"
,
"[{a: &anchor \"b\"}]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -587,7 +627,10 @@ ENGINE_TEST(SeqIMap5Dquo,
}
ENGINE_TEST(SeqIMap5Ref,
("[a: *ref]", "[{a: *ref}]"),
"[a: *ref]"
,
"[{a: *ref}]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -612,7 +655,10 @@ ENGINE_TEST(SeqIMap5Ref,
}
ENGINE_TEST(SeqIMap5QmrkNone0,
("[? ,]", "[{: }]"),
"[? ,]"
,
"[{: }]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -637,7 +683,10 @@ ENGINE_TEST(SeqIMap5QmrkNone0,
}
ENGINE_TEST(SeqIMap5QmrkNone1,
("[? ]", "[{: }]"),
"[? ]"
,
"[{: }]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -662,7 +711,10 @@ ENGINE_TEST(SeqIMap5QmrkNone1,
}
ENGINE_TEST(SeqIMap5QmrkSquo1,
("[? &anchor 'squo' ]", "[{&anchor 'squo': }]"),
"[? &anchor 'squo' ]"
,
"[{&anchor 'squo': }]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -689,7 +741,10 @@ ENGINE_TEST(SeqIMap5QmrkSquo1,
}
ENGINE_TEST(SeqIMap5QmrkDquo1,
("[? &anchor \"dquo\" ]", "[{&anchor \"dquo\": }]"),
"[? &anchor \"dquo\" ]"
,
"[{&anchor \"dquo\": }]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -716,7 +771,10 @@ ENGINE_TEST(SeqIMap5QmrkDquo1,
}
ENGINE_TEST(SeqIMap5QmrkRef1,
("[? a: *ref]", "[{a: *ref}]"),
"[? a: *ref]"
,
"[{a: *ref}]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -741,7 +799,10 @@ ENGINE_TEST(SeqIMap5QmrkRef1,
}
ENGINE_TEST(SeqIMap5QmrkRef2,
("[? *ref: b]", "[{*ref : b}]"),
"[? *ref: b]"
,
"[{*ref : b}]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -766,8 +827,11 @@ ENGINE_TEST(SeqIMap5QmrkRef2,
}
ENGINE_TEST(SeqIMap5QmrkSeq,
(HAS_CONTAINER_KEYS,
"[? &anchor [a, seq]: ]", "[{&anchor [a, seq]: }]"),
HAS_CONTAINER_KEYS,
"[? &anchor [a, seq]: ]"
,
"[{&anchor [a, seq]: }]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"
@@ -800,8 +864,11 @@ ENGINE_TEST(SeqIMap5QmrkSeq,
}
ENGINE_TEST(SeqIMap5QmrkMap,
(HAS_CONTAINER_KEYS,
"[? &anchor {a: map}: ]", "[{&anchor {a: map}: }]"),
HAS_CONTAINER_KEYS,
"[? &anchor {a: map}: ]"
,
"[{&anchor {a: map}: }]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"

View File

@@ -8,7 +8,8 @@ namespace yml {
ENGINE_TEST(PlainScalarUnfiltered,
("foo: bar\n"),
"foo: bar\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -33,7 +34,10 @@ ENGINE_TEST(PlainScalarUnfiltered,
//-----------------------------------------------------------------------------
ENGINE_TEST(PlainScalarWithColon0,
("a::\n", "a:: \n"),
"a::\n"
,
"a:: \n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -54,7 +58,8 @@ ENGINE_TEST(PlainScalarWithColon0,
}
ENGINE_TEST(PlainScalarWithColon1,
("key ends with two colons::: value\n"),
"key ends with two colons::: value\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -75,12 +80,14 @@ ENGINE_TEST(PlainScalarWithColon1,
}
ENGINE_TEST(PlainScalarWithColonSeq,
("- ::\n"
"- x::\n"
"- :x::\n",
"- :: \n"
"- x:: \n"
"- :x:: \n"),
"- ::\n"
"- x::\n"
"- :x::\n"
,
"- :: \n"
"- x:: \n"
"- :x:: \n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -126,7 +133,8 @@ ENGINE_TEST(PlainScalarWithColonSeq,
//-----------------------------------------------------------------------------
ENGINE_TEST(BlockPlainScalarCommaDoc,
("a, b\n"),
"a, b\n"
,
"+STR\n"
"+DOC\n"
"=VAL :a, b\n"
@@ -141,7 +149,8 @@ ENGINE_TEST(BlockPlainScalarCommaDoc,
}
ENGINE_TEST(BlockPlainScalarCommaMap,
("a, b: c, d\n"),
"a, b: c, d\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -162,7 +171,8 @@ ENGINE_TEST(BlockPlainScalarCommaMap,
}
ENGINE_TEST(BlockPlainScalarCommaSeq,
("- a, b\n- c, d\n"),
"- a, b\n- c, d\n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -299,13 +309,15 @@ ENGINE_TEST_ERRLOC(ExtraTokensFlow2Map5_1, Location(3,1), "---\n{a: b}\n-")
ENGINE_TEST_ERRLOC(ExtraTokensScalar0, Location(2,6), "word1 # comment\nword2")
ENGINE_TEST(ExtraTokensNoFalseError0,
("---\n"
"map : {foo: bar, notag: none}\n"
"seq : [foo, bar]\n"
"...\n",
"---\n"
"map: {foo: bar,notag: none}\n"
"seq: [foo,bar]\n"),
"---\n"
"map : {foo: bar, notag: none}\n"
"seq : [foo, bar]\n"
"...\n"
,
"---\n"
"map: {foo: bar,notag: none}\n"
"seq: [foo,bar]\n"
,
"+STR\n"
"+DOC ---\n"
"+MAP\n"
@@ -349,13 +361,15 @@ ENGINE_TEST(ExtraTokensNoFalseError0,
}
ENGINE_TEST(ExtraTokensNoFalseError1,
("---\n"
"*mapref : {foo: bar, notag: none}\n"
"*seqref : [foo, bar]\n"
"...\n",
"---\n"
"*mapref : {foo: bar,notag: none}\n"
"*seqref : [foo,bar]\n"),
"---\n"
"*mapref : {foo: bar, notag: none}\n"
"*seqref : [foo, bar]\n"
"...\n"
,
"---\n"
"*mapref : {foo: bar,notag: none}\n"
"*seqref : [foo,bar]\n"
,
"+STR\n"
"+DOC ---\n"
"+MAP\n"
@@ -402,8 +416,10 @@ ENGINE_TEST(ExtraTokensNoFalseError1,
//-----------------------------------------------------------------------------
ENGINE_TEST(PlainScalarDoc0,
("a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~",
"a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\n"),
"a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~"
,
"a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\n"
,
"+STR\n"
"+DOC\n"
"=VAL :a!\"#$%&'()*+,-./09:;<=>?@AZ[\\\\]^_`az{|}~\n"
@@ -417,8 +433,10 @@ ENGINE_TEST(PlainScalarDoc0,
___(ps.end_stream());
}
ENGINE_TEST(PlainScalarBlockSeq0,
("- a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~",
"- a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\n"),
"- a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~"
,
"- a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\n"
,
"+STR\n"
"+DOC\n"
"+SEQ\n"
@@ -436,8 +454,9 @@ ENGINE_TEST(PlainScalarBlockSeq0,
___(ps.end_stream());
}
ENGINE_TEST(PlainScalarBlockMap0,
("key: a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\n"
"a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~: val\n"),
"key: a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\n"
"a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~: val\n"
,
"+STR\n"
"+DOC\n"
"+MAP\n"
@@ -469,9 +488,11 @@ ENGINE_TEST_ERRLOC(PlainScalarFlow0Seq1_1, Location(2,28), "[\n"
"a!\"#$%&'()*+,-./09:;<=>?@AZ{|}^_`az{|}~\n]")
ENGINE_TEST_ERRLOC(PlainScalarFlow1Seq0, Location(1,38), "[a!\"#$%&'()*+,-./09:;<=>?@]^_`az{|}~]")
ENGINE_TEST(PlainScalarFlow0Seq1,
("[\n"
"a!\"#$%&'()*+,-./09:;<=>?@AZ\\\n]",
"[a!\"#$%&'()*+,-./09:;<=>?@AZ\\]"),
"[\n"
"a!\"#$%&'()*+,-./09:;<=>?@AZ\\\n]"
,
"[a!\"#$%&'()*+,-./09:;<=>?@AZ\\]"
,
"+STR\n"
"+DOC\n"
"+SEQ []\n"

View File

@@ -80,39 +80,39 @@ void test_expected_error_tree_from_yaml(std::string const& parsed_yaml, Location
}
void test_engine_testsuite_from_yaml(ReferenceYaml const& yaml, std::string const& expected_events, ParserOptions opts)
void test_engine_testsuite_from_yaml(EngineEvtTestCase const& tc, std::string const& parsed_yaml, ParserOptions opts)
{
extra::EventHandlerTestSuite::EventSink sink;
extra::EventHandlerTestSuite handler(&sink);
handler.reset();
ParseEngine<extra::EventHandlerTestSuite> parser(&handler, opts);
std::string copy = yaml.parsed;
std::string copy = parsed_yaml;
parser.parse_in_place_ev("(testyaml)", to_substr(copy));
csubstr result = sink;
_c4dbgpf("~~~\n{}~~~\n", result);
EXPECT_EQ(std::string(result.str, result.len), expected_events);
EXPECT_EQ(std::string(result.str, result.len), tc.expected_events);
}
void test_engine_ints_from_yaml(ReferenceYaml const& yaml, std::string const& expected_events, ParserOptions opts)
void test_engine_ints_from_yaml(EngineEvtTestCase const& tc, std::string const& parsed_yaml, ParserOptions opts)
{
extra::EventHandlerInts handler{};
using IntType = extra::ievt::DataType;
//NOTE! crashes in MIPS64 Debug c++20 (but not c++11) when size is 0:
//std::vector<IntType> actual_evts(empty.size());
std::vector<IntType> actual_evts; // DO THIS!
size_t size_reference = num_ints(yaml.expected_ints.data(), yaml.expected_ints.size());
int size_estimated = extra::estimate_events_ints_size(to_csubstr(yaml.parsed));
size_t size_reference = num_ints(tc.expected_ints.data(), tc.expected_ints.size());
int size_estimated = extra::estimate_events_ints_size(to_csubstr(parsed_yaml));
// there was an error in gcc<5 where the copy buffer was NOT
// assigned when using a std::string:
//std::string copy = yaml.parsed; gcc<5 ERROR, see below
std::vector<char> copy(yaml.parsed.begin(), yaml.parsed.end());
std::vector<char> copy(parsed_yaml.begin(), parsed_yaml.end());
_c4dbgpf("parsing: [{}]{}", copy.size(), c4::fmt::hex(copy.data()));
std::vector<char> arena(copy.size());
handler.reset(to_csubstr(copy), to_substr(arena), actual_evts.data(), (IntType)actual_evts.size());
ParseEngine<extra::EventHandlerInts> parser(&handler, opts);
parser.parse_in_place_ev("(testyaml)", to_substr(copy));
EXPECT_GE(size_estimated, handler.required_size_events());
if(yaml.expected_ints_enabled)
if(tc.expected_ints_enabled)
{
EXPECT_EQ(size_reference, handler.required_size_events());
}
@@ -121,7 +121,7 @@ void test_engine_ints_from_yaml(ReferenceYaml const& yaml, std::string const& ex
{
if(sz > actual_evts.size())
actual_evts.resize(sz);
copy.assign(yaml.parsed.begin(), yaml.parsed.end());
copy.assign(parsed_yaml.begin(), parsed_yaml.end());
if(handler.required_size_arena() > arena.size())
arena.resize(handler.required_size_arena());
_c4dbgpf("parsing again: (before) [{}]{}", copy.size(), c4::fmt::hex(copy.data()));
@@ -138,17 +138,17 @@ void test_engine_ints_from_yaml(ReferenceYaml const& yaml, std::string const& ex
RYML_TRACE_FMT("invariants", 0);
extra::test_events_ints_invariants(to_csubstr(copy), to_csubstr(arena), actual_evts.data(), (IntType)actual_evts.size());
}
if (yaml.expected_ints_enabled)
if (tc.expected_ints_enabled)
{
RYML_TRACE_FMT("here", 0);
test_events_ints(yaml.expected_ints.data(), yaml.expected_ints.size(),
test_events_ints(tc.expected_ints.data(), tc.expected_ints.size(),
actual_evts.data(), actual_evts.size(),
to_csubstr(yaml.parsed), to_csubstr(copy), to_csubstr(arena));
to_csubstr(parsed_yaml), to_csubstr(copy), to_csubstr(arena));
}
{
RYML_TRACE_FMT("cmp", 0);
std::string actual_test_suite_evts = extra::events_ints_to_testsuite<std::string>(to_csubstr(copy), to_csubstr(arena), actual_evts.data(), (IntType)actual_evts.size());
test_compare_events(to_csubstr(expected_events),
test_compare_events(to_csubstr(tc.expected_events),
to_csubstr(actual_test_suite_evts),
/*ignore_doc_style*/false,
/*ignore_container_style*/false,
@@ -157,11 +157,11 @@ void test_engine_ints_from_yaml(ReferenceYaml const& yaml, std::string const& ex
}
}
void test_engine_tree_from_yaml(ReferenceYaml const& yaml, ParserOptions opts)
void test_engine_tree_from_yaml(EngineEvtTestCase const& tc, std::string const& parsed_yaml, ParserOptions opts)
{
if(yaml.test_case_flags & HAS_CONTAINER_KEYS)
if(tc.test_case_flags & HAS_CONTAINER_KEYS)
{
test_expected_error_tree_from_yaml(yaml.parsed, yaml.expected_error_location);
test_expected_error_tree_from_yaml(parsed_yaml, tc.expected_error_location);
return;
}
Tree tree = {};
@@ -170,60 +170,55 @@ void test_engine_tree_from_yaml(ReferenceYaml const& yaml, ParserOptions opts)
ParseEngine<EventHandlerTree> parser(&handler, opts);
ASSERT_EQ(&handler, parser.m_evt_handler);
ASSERT_EQ(&tree, parser.m_evt_handler->m_tree);
std::string copy = yaml.parsed;
std::string copy = parsed_yaml;
parser.parse_in_place_ev("(testyaml)", to_substr(copy));
#ifdef RYML_DBG
print_tree(tree);
#endif
std::string actual = emitrs_yaml<std::string>(tree);
_c4dbgpf("~~~\n{}~~~\n", actual);
EXPECT_EQ(actual, yaml.emitted);
EXPECT_EQ(actual, tc.emitted);
}
void test_engine_testsuite_from_yaml_with_comments(ReferenceYaml const& yaml, std::string const& expected_events, ParserOptions opts)
void test_engine_testsuite_from_yaml_with_comments(EngineEvtTestCase const& yaml, ParserOptions opts)
{
if(yaml.test_case_flags & HAS_CONTAINER_KEYS)
return;
if(yaml.test_case_flags & HAS_MULTILINE_SCALAR)
return;
ReferenceYaml transformed = yaml;
const auto injected_comments = inject_comments(yaml.parsed);
for(size_t i = 0; i < injected_comments.size(); ++i)
{
const auto & transformed_str = injected_comments[i];
const std::string& transformed_str = injected_comments[i];
_c4dbgpf("transformed[{}/{}]=~~~[{}]\n{}\n~~~", i, injected_comments.size(), transformed_str.size(), to_csubstr(transformed_str));
SCOPED_TRACE(transformed_str);
SCOPED_TRACE("commented");
transformed.parsed = transformed_str;
test_engine_testsuite_from_yaml(transformed, expected_events, opts);
test_engine_testsuite_from_yaml(yaml, transformed_str, opts);
}
}
void test_engine_ints_from_yaml_with_comments(ReferenceYaml const& yaml, std::string const& expected_events, ParserOptions opts)
void test_engine_ints_from_yaml_with_comments(EngineEvtTestCase const& yaml, ParserOptions opts)
{
if(yaml.test_case_flags & HAS_MULTILINE_SCALAR)
return;
ReferenceYaml transformed = yaml;
const auto injected_comments = inject_comments(yaml.parsed);
for(size_t i = 0; i < injected_comments.size(); ++i)
{
const auto & transformed_str = injected_comments[i];
const std::string& transformed_str = injected_comments[i];
_c4dbgpf("transformed[{}/{}]=~~~[{}]\n{}\n~~~", i, injected_comments.size(), transformed_str.size(), to_csubstr(transformed_str));
SCOPED_TRACE(transformed_str);
SCOPED_TRACE("commented");
transformed.parsed = transformed_str;
test_engine_ints_from_yaml(transformed, expected_events, opts);
test_engine_ints_from_yaml(yaml, transformed_str, opts);
}
}
void test_engine_tree_from_yaml_with_comments(ReferenceYaml const& yaml, ParserOptions opts)
void test_engine_tree_from_yaml_with_comments(EngineEvtTestCase const& yaml, ParserOptions opts)
{
if(yaml.test_case_flags & HAS_CONTAINER_KEYS)
return;
if(yaml.test_case_flags & HAS_MULTILINE_SCALAR)
return;
ReferenceYaml transformed = yaml;
const auto injected_comments = inject_comments(yaml.parsed);
for(size_t i = 0; i < injected_comments.size(); ++i)
{
@@ -231,11 +226,15 @@ void test_engine_tree_from_yaml_with_comments(ReferenceYaml const& yaml, ParserO
_c4dbgpf("transformed[{}/{}]=~~~[{}]\n{}\n~~~", i, injected_comments.size(), transformed_str.size(), to_csubstr(transformed_str));
SCOPED_TRACE(transformed_str);
SCOPED_TRACE("commented");
transformed.parsed = transformed_str;
test_engine_tree_from_yaml(transformed, opts);
test_engine_ints_from_yaml(yaml, transformed_str, opts);
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
csubstr parse_anchor_and_tag(csubstr tokens, OptionalScalar *anchor, OptionalScalar *tag)
{
*anchor = OptionalScalar{};

View File

@@ -12,6 +12,9 @@
#include <gtest/gtest.h>
#include "./test_lib/test_case.hpp"
#include "./test_lib/test_events_ints_helpers.hpp"
#include "testsuite/testsuite_events.hpp"
#include "c4/yml/extra/ints_to_testsuite.hpp"
#include "c4/yml/extra/ints_utils.hpp"
#include "c4/yml/extra/event_handler_testsuite.hpp"
#include "c4/yml/extra/event_handler_ints.hpp"
@@ -20,85 +23,6 @@ namespace c4 {
namespace yml {
struct ReferenceYaml
{
ReferenceYaml( std::string const& s ) : test_case_flags(), expected_error_location(), parsed(s), emitted(s), expected_ints(), expected_ints_enabled(false) {}
ReferenceYaml( std::string const& p, std::string const& e) : test_case_flags(), expected_error_location(), parsed(p), emitted(e), expected_ints(), expected_ints_enabled(false) {}
ReferenceYaml(TestCaseFlags_e tf, std::string const& p, std::string const& e) : test_case_flags(tf), expected_error_location(), parsed(p), emitted(e), expected_ints(), expected_ints_enabled(false) {}
ReferenceYaml(TestCaseFlags_e tf, std::string const& p ) : test_case_flags(tf), expected_error_location(), parsed(p), emitted(p), expected_ints(), expected_ints_enabled(false) {}
ReferenceYaml( Location linecol_, std::string const& p ) : test_case_flags(), expected_error_location(linecol_), parsed(p), emitted(p), expected_ints(), expected_ints_enabled(false) { RYML_ASSERT(linecol_); }
ReferenceYaml(TestCaseFlags_e tf, Location linecol_, std::string const& p, std::string const& e) : test_case_flags(tf), expected_error_location(linecol_), parsed(p), emitted(e), expected_ints(), expected_ints_enabled(false) { RYML_ASSERT(linecol_); }
ReferenceYaml(TestCaseFlags_e tf, Location linecol_, std::string const& p ) : test_case_flags(tf), expected_error_location(linecol_), parsed(p), emitted(p), expected_ints(), expected_ints_enabled(false) { RYML_ASSERT(linecol_); }
ReferenceYaml( std::string const& s , std::vector<extra::IntEventWithScalar> ints) : test_case_flags(), expected_error_location(), parsed(s), emitted(s), expected_ints(std::move(ints)), expected_ints_enabled(true) {}
ReferenceYaml( std::string const& p, std::string const& e, std::vector<extra::IntEventWithScalar> ints) : test_case_flags(), expected_error_location(), parsed(p), emitted(e), expected_ints(std::move(ints)), expected_ints_enabled(true) {}
ReferenceYaml(TestCaseFlags_e tf, std::string const& p, std::string const& e, std::vector<extra::IntEventWithScalar> ints) : test_case_flags(tf), expected_error_location(), parsed(p), emitted(e), expected_ints(std::move(ints)), expected_ints_enabled(true) {}
ReferenceYaml(TestCaseFlags_e tf, std::string const& p , std::vector<extra::IntEventWithScalar> ints) : test_case_flags(tf), expected_error_location(), parsed(p), emitted(p), expected_ints(std::move(ints)), expected_ints_enabled(true) {}
ReferenceYaml( Location linecol_, std::string const& p , std::vector<extra::IntEventWithScalar> ints) : test_case_flags(), expected_error_location(linecol_), parsed(p), emitted(p), expected_ints(std::move(ints)), expected_ints_enabled(true) { RYML_ASSERT(linecol_); }
ReferenceYaml(TestCaseFlags_e tf, Location linecol_, std::string const& p, std::string const& e, std::vector<extra::IntEventWithScalar> ints) : test_case_flags(tf), expected_error_location(linecol_), parsed(p), emitted(e), expected_ints(std::move(ints)), expected_ints_enabled(true) { RYML_ASSERT(linecol_); }
ReferenceYaml(TestCaseFlags_e tf, Location linecol_, std::string const& p , std::vector<extra::IntEventWithScalar> ints) : test_case_flags(tf), expected_error_location(linecol_), parsed(p), emitted(p), expected_ints(std::move(ints)), expected_ints_enabled(true) { RYML_ASSERT(linecol_); }
TestCaseFlags_e test_case_flags;
Location expected_error_location;
std::string parsed;
std::string emitted;
std::vector<extra::IntEventWithScalar> expected_ints;
bool expected_ints_enabled;
};
template<template<class> class EventProducerFn>
C4_NO_INLINE void test_engine_str_from_testsuite(std::string const& expected_events)
{
extra::EventHandlerTestSuite::EventSink sink;
extra::EventHandlerTestSuite handler(&sink);
handler.reset();
EventProducerFn<extra::EventHandlerTestSuite> event_producer;
event_producer(handler);
csubstr result = sink;
_c4dbgpf("~~~\n{}~~~\n", result);
EXPECT_EQ(std::string(result.str, result.len), expected_events);
}
template<template<class> class EventProducerFn>
C4_NO_INLINE void test_engine_tree_from_testsuite(ReferenceYaml const& yaml)
{
if(yaml.test_case_flags & HAS_CONTAINER_KEYS)
{
ExpectError::check_error([&]{
Tree tree = {};
EventHandlerTree handler(&tree, tree.root_id());
EventProducerFn<EventHandlerTree> event_producer;
event_producer(handler);
});
}
else
{
Tree tree = {};
EventHandlerTree handler(&tree, tree.root_id());
EventProducerFn<EventHandlerTree> event_producer;
event_producer(handler);
#ifdef RYML_DBG
print_tree(tree);
#endif
std::string actual = emitrs_yaml<std::string>(tree);
_c4dbgpf("~~~\n{}~~~\n", actual);
EXPECT_EQ(actual, yaml.emitted);
}
}
void test_engine_testsuite_from_yaml(ReferenceYaml const& yaml, std::string const& expected_events, ParserOptions opts);
void test_engine_ints_from_yaml(ReferenceYaml const& yaml, std::string const& expected_events, ParserOptions opts);
void test_engine_tree_from_yaml(ReferenceYaml const& yaml, ParserOptions opts);
void test_engine_testsuite_from_yaml_with_comments(ReferenceYaml const& yaml, std::string const& expected_events, ParserOptions opts);
void test_engine_ints_from_yaml_with_comments(ReferenceYaml const& yaml, std::string const& expected_events, ParserOptions opts);
void test_engine_tree_from_yaml_with_comments(ReferenceYaml const& yaml, ParserOptions opts);
void test_expected_error_testsuite_from_yaml(std::string const& parsed_yaml, Location const& expected_error_location={});
void test_expected_error_ints_from_yaml(std::string const& parsed_yaml, Location const& expected_error_location={});
void test_expected_error_tree_from_yaml(std::string const& parsed_yaml, Location const& expected_error_location={});
//-----------------------------------------------------------------------------
struct OptionalScalar
@@ -122,6 +46,236 @@ void test_compare_events(csubstr ref_evts,
bool ignore_tag_normalization);
//-----------------------------------------------------------------------------
struct EngineEvtTestCase
{
EngineEvtTestCase( std::string s , std::string ev) : test_case_flags( ), expected_error_location( ), parsed(s ), emitted(std::move(s)), expected_events(std::move(ev)), expected_ints(), expected_ints_enabled(false) {}
EngineEvtTestCase( std::string p, std::string e, std::string ev) : test_case_flags( ), expected_error_location( ), parsed(std::move(p)), emitted(std::move(e)), expected_events(std::move(ev)), expected_ints(), expected_ints_enabled(false) {}
EngineEvtTestCase(TestCaseFlags_e tf, std::string p, std::string e, std::string ev) : test_case_flags(tf), expected_error_location( ), parsed(std::move(p)), emitted(std::move(e)), expected_events(std::move(ev)), expected_ints(), expected_ints_enabled(false) {}
EngineEvtTestCase(TestCaseFlags_e tf, std::string p , std::string ev) : test_case_flags(tf), expected_error_location( ), parsed(p ), emitted(std::move(p)), expected_events(std::move(ev)), expected_ints(), expected_ints_enabled(false) {}
EngineEvtTestCase( Location linecol_, std::string p , std::string ev) : test_case_flags( ), expected_error_location(linecol_), parsed(p ), emitted(std::move(p)), expected_events(std::move(ev)), expected_ints(), expected_ints_enabled(false) { RYML_ASSERT(linecol_); }
EngineEvtTestCase(TestCaseFlags_e tf, Location linecol_, std::string p, std::string e, std::string ev) : test_case_flags(tf), expected_error_location(linecol_), parsed(std::move(p)), emitted(std::move(e)), expected_events(std::move(ev)), expected_ints(), expected_ints_enabled(false) { RYML_ASSERT(linecol_); }
EngineEvtTestCase(TestCaseFlags_e tf, Location linecol_, std::string p , std::string ev) : test_case_flags(tf), expected_error_location(linecol_), parsed(p ), emitted(std::move(p)), expected_events(std::move(ev)), expected_ints(), expected_ints_enabled(false) { RYML_ASSERT(linecol_); }
EngineEvtTestCase( std::string s , std::string ev, std::vector<extra::IntEventWithScalar> ints) : test_case_flags( ), expected_error_location( ), parsed(s ), emitted(std::move(s)), expected_events(std::move(ev)), expected_ints(std::move(ints)), expected_ints_enabled(true) {}
EngineEvtTestCase( std::string p, std::string e, std::string ev, std::vector<extra::IntEventWithScalar> ints) : test_case_flags( ), expected_error_location( ), parsed(std::move(p)), emitted(std::move(e)), expected_events(std::move(ev)), expected_ints(std::move(ints)), expected_ints_enabled(true) {}
EngineEvtTestCase(TestCaseFlags_e tf, std::string p, std::string e, std::string ev, std::vector<extra::IntEventWithScalar> ints) : test_case_flags(tf), expected_error_location( ), parsed(std::move(p)), emitted(std::move(e)), expected_events(std::move(ev)), expected_ints(std::move(ints)), expected_ints_enabled(true) {}
EngineEvtTestCase(TestCaseFlags_e tf, std::string p , std::string ev, std::vector<extra::IntEventWithScalar> ints) : test_case_flags(tf), expected_error_location( ), parsed(p ), emitted(std::move(p)), expected_events(std::move(ev)), expected_ints(std::move(ints)), expected_ints_enabled(true) {}
EngineEvtTestCase( Location linecol_, std::string p , std::string ev, std::vector<extra::IntEventWithScalar> ints) : test_case_flags( ), expected_error_location(linecol_), parsed(p ), emitted(std::move(p)), expected_events(std::move(ev)), expected_ints(std::move(ints)), expected_ints_enabled(true) { RYML_ASSERT(linecol_); }
EngineEvtTestCase(TestCaseFlags_e tf, Location linecol_, std::string p, std::string e, std::string ev, std::vector<extra::IntEventWithScalar> ints) : test_case_flags(tf), expected_error_location(linecol_), parsed(std::move(p)), emitted(std::move(e)), expected_events(std::move(ev)), expected_ints(std::move(ints)), expected_ints_enabled(true) { RYML_ASSERT(linecol_); }
EngineEvtTestCase(TestCaseFlags_e tf, Location linecol_, std::string p , std::string ev, std::vector<extra::IntEventWithScalar> ints) : test_case_flags(tf), expected_error_location(linecol_), parsed( p), emitted(std::move(p)), expected_events(std::move(ev)), expected_ints(std::move(ints)), expected_ints_enabled(true) { RYML_ASSERT(linecol_); }
TestCaseFlags_e test_case_flags;
Location expected_error_location;
std::string parsed;
std::string emitted;
std::string expected_events;
std::vector<extra::IntEventWithScalar> expected_ints;
bool expected_ints_enabled;
};
template<template<class> class EventProducerFn>
C4_NO_INLINE void test_engine_testsuite_from_events(const EngineEvtTestCase& tc)
{
extra::EventHandlerTestSuite::EventSink sink;
extra::EventHandlerTestSuite handler(&sink);
handler.reset();
EventProducerFn<extra::EventHandlerTestSuite> event_producer;
event_producer(handler);
csubstr result = sink;
_c4dbgpf("~~~\n{}~~~\n", result);
EXPECT_EQ(std::string(result.str, result.len), tc.expected_events);
}
struct Separator {};
template<class Handler, class ArgTransformer>
struct EventTransformer
{
Handler handler;
ArgTransformer transformer{&handler, {}};
void start_parse(const char* filename, c4::yml::detail::pfn_relocate_arena relocate_arena, void *relocate_arena_data)
{
handler.start_parse(filename, relocate_arena, relocate_arena_data);
}
#define fwd(evt) void evt() { handler.evt(); }
#define fwds(evt) void evt(csubstr s) { handler.evt(transformer(s)); }
fwd(begin_stream)
fwd(end_stream)
fwd(begin_doc)
fwd(end_doc)
fwd(begin_doc_expl)
fwd(end_doc_expl)
fwd(begin_map_key_flow)
fwd(begin_map_key_block)
fwd(begin_map_val_flow)
fwd(begin_map_val_block)
fwd(end_map)
fwd(begin_seq_key_flow)
fwd(begin_seq_key_block)
fwd(begin_seq_val_flow)
fwd(begin_seq_val_block)
fwd(end_seq)
fwd(add_sibling)
fwd(actually_val_is_first_key_of_new_map_flow)
fwd(actually_val_is_first_key_of_new_map_block)
fwd(mark_key_scalar_unfiltered)
fwd(mark_val_scalar_unfiltered)
fwd(set_key_scalar_plain_empty)
fwd(set_val_scalar_plain_empty)
fwds(set_key_scalar_plain)
fwds(set_val_scalar_plain)
fwds(set_key_scalar_dquoted)
fwds(set_val_scalar_dquoted)
fwds(set_key_scalar_squoted)
fwds(set_val_scalar_squoted)
fwds(set_key_scalar_literal)
fwds(set_val_scalar_literal)
fwds(set_key_scalar_folded)
fwds(set_val_scalar_folded)
fwds(set_key_anchor)
fwds(set_val_anchor)
fwds(set_key_ref)
fwds(set_val_ref)
fwds(set_key_tag)
fwds(set_val_tag)
fwds(add_directive)
#undef fwd
#undef fwds
};
template<class Handler>
struct TransformToSourceBufferOrArena
{
Handler *handler;
csubstr src;
csubstr operator() (csubstr s) const
{
size_t pos = src.find(s);
if(pos != csubstr::npos)
{
RYML_ASSERT(pos + s.len <= src.len);
return src.sub(pos, s.len);
}
substr dst = handler->alloc_arena(s.len);
if(s.len) memcpy(dst.str, s.str, s.len);
return dst;
}
};
template<template<class> class EventProducerFn>
C4_NO_INLINE void test_engine_ints_from_events(EngineEvtTestCase const& tc)
{
SCOPED_TRACE("ints_from_events");
using Helper = EventTransformer<extra::EventHandlerInts, TransformToSourceBufferOrArena<extra::EventHandlerInts>>;
Helper helper;
extra::EventHandlerInts &handler = helper.handler;
std::string src = tc.parsed;
std::string arena;
std::vector<int> ints((size_t)extra::estimate_events_ints_size(to_csubstr(src)));
arena.resize(src.size());
handler.reset(to_substr(src), to_substr(arena), ints.data(), (int)ints.size());
helper.transformer.src = to_csubstr(src);
EventProducerFn<Helper> event_producer;
event_producer(helper);
ASSERT_LE(handler.required_size_events(), (int)ints.size());
if(!handler.fits_buffers())
{
// must be because the arena is too small
ASSERT_GT(handler.required_size_arena(), (int)arena.size());
arena.resize(handler.required_size_arena());
// try again
src.assign(tc.parsed.begin(), tc.parsed.end());
helper.transformer.src = to_csubstr(src);
handler.reset(to_substr(src), to_substr(arena), ints.data(), (int)ints.size());
event_producer(helper);
}
ASSERT_TRUE(handler.fits_buffers());
ints.resize((size_t)handler.required_size_events());
#ifdef RYML_DBG
extra::events_ints_print(to_csubstr(src), to_csubstr(arena), ints.data(), (int)ints.size());
#endif
{
SCOPED_TRACE("test_invariants");
extra::test_events_ints_invariants(to_csubstr(src), to_csubstr(arena), ints.data(), (int)ints.size());
}
if(tc.expected_ints_enabled)
{
SCOPED_TRACE("compare_ints");
extra::test_events_ints(tc.expected_ints.data(), tc.expected_ints.size(),
ints.data(), ints.size(),
to_csubstr(tc.parsed),
to_csubstr(src),
to_csubstr(arena));
}
{
std::string actual_testsuite_events = extra::events_ints_to_testsuite<std::string>(to_csubstr(src), to_csubstr(arena), ints.data(), (int)ints.size());
_c4dbgpf("~~~\n{}~~~\n", actual_testsuite_events);
test_compare_events(to_csubstr(tc.expected_events),
to_csubstr(actual_testsuite_events),
/*ignore_doc_style*/false,
/*ignore_container_style*/false,
/*ignore_scalar_style*/false,
/*ignore_tag_normalization*/true);
}
}
template<template<class> class EventProducerFn>
C4_NO_INLINE void test_engine_tree_from_events(EngineEvtTestCase const& tc)
{
if(tc.test_case_flags & HAS_CONTAINER_KEYS)
{
ExpectError::check_error([&]{
Tree tree = {};
EventHandlerTree handler(&tree, tree.root_id());
EventProducerFn<EventHandlerTree> event_producer;
event_producer(handler);
});
}
else
{
Tree tree = {};
EventHandlerTree handler(&tree, tree.root_id());
EventProducerFn<EventHandlerTree> event_producer;
event_producer(handler);
#ifdef RYML_DBG
print_tree(tree);
#endif
std::string actual = emitrs_yaml<std::string>(tree);
_c4dbgpf("~~~\n{}~~~\n", actual);
EXPECT_EQ(actual, tc.emitted);
}
}
void test_engine_testsuite_from_yaml(EngineEvtTestCase const& yaml, std::string const& parsed_yaml, ParserOptions opts);
void test_engine_ints_from_yaml(EngineEvtTestCase const& yaml, std::string const& parsed_yaml, ParserOptions opts);
void test_engine_tree_from_yaml(EngineEvtTestCase const& yaml, std::string const& parsed_yaml, ParserOptions opts);
inline void test_engine_testsuite_from_yaml(EngineEvtTestCase const& yaml, ParserOptions opts) { test_engine_testsuite_from_yaml(yaml, yaml.parsed, opts); }
inline void test_engine_ints_from_yaml(EngineEvtTestCase const& yaml, ParserOptions opts) { test_engine_ints_from_yaml(yaml, yaml.parsed, opts); }
inline void test_engine_tree_from_yaml(EngineEvtTestCase const& yaml, ParserOptions opts) { test_engine_tree_from_yaml(yaml, yaml.parsed, opts); }
void test_engine_testsuite_from_yaml_with_comments(EngineEvtTestCase const& yaml, ParserOptions opts);
void test_engine_ints_from_yaml_with_comments(EngineEvtTestCase const& yaml, ParserOptions opts);
void test_engine_tree_from_yaml_with_comments(EngineEvtTestCase const& yaml, ParserOptions opts);
void test_expected_error_testsuite_from_yaml(std::string const& parsed_yaml, Location const& expected_error_location={});
void test_expected_error_ints_from_yaml(std::string const& parsed_yaml, Location const& expected_error_location={});
void test_expected_error_tree_from_yaml(std::string const& parsed_yaml, Location const& expected_error_location={});
//-----------------------------------------------------------------------------
#ifdef RYML_DBG
@@ -197,53 +351,72 @@ TEST(EngineTest, name##_err_tree_from_yaml) \
//-----------------------------------------------------------------------------
/* declare a parse engine test for the existing event handlers */
#define ENGINE_TEST(name, refyaml, events) \
ENGINE_TEST_(name, ParserOptions{}, refyaml, events)
#define ENGINE_TEST_(name, opts, refyaml, events) \
/* declare a parse engine test for the existing event handlers.
* The extra arguments are for the ctor of EngineEvtTestCase */
#define ENGINE_TEST(name, ...) ENGINE_TEST_(name, ParserOptions{}, __VA_ARGS__)
/* declare a parse engine test for the existing event handlers.
* The extra arguments are for the ctor of EngineEvtTestCase */
#define ENGINE_TEST_(name, opts, ...) \
\
\
static const EngineEvtTestCase test_case_##name(__VA_ARGS__); \
\
\
/* declare a function that will produce a \
sequence of events */ \
template<class Ps> \
void name##_impl(Ps &ps); \
template<class EvtHandlerClass> \
void name##_impl(EvtHandlerClass &handler); \
\
\
/* package the function into a class */ \
template<class Ps> \
template<class EvtHandlerClass> \
struct name \
{ \
void operator() (Ps &ps) \
void operator() (EvtHandlerClass &handler) \
{ \
name##_impl(ps); \
name##_impl(handler); \
} \
}; \
\
\
TEST(EngineTest, name##_str_from_testsuite) \
TEST(EngineTest, name##_testsuite_from_events) \
{ \
_RYML_SHOWFILELINE(name); \
SCOPED_TRACE(#name "_str_from_testsuite"); \
test_engine_str_from_testsuite<name>(events); \
SCOPED_TRACE(#name "_testsuite_from_events"); \
auto const &tc = test_case_##name; \
test_engine_testsuite_from_events<name>(tc); \
_RYML_SHOWFILELINE(name); \
} \
\
TEST(EngineTest, name##_tree_from_testsuite) \
TEST(EngineTest, name##_ints_from_events) \
{ \
_RYML_SHOWFILELINE(name); \
SCOPED_TRACE(#name "_tree_from_testsuite"); \
ReferenceYaml yaml refyaml; \
test_engine_tree_from_testsuite<name>(yaml); \
SCOPED_TRACE(#name "_ints_from_events"); \
auto const &tc = test_case_##name; \
test_engine_ints_from_events<name>(tc); \
_RYML_SHOWFILELINE(name); \
} \
\
TEST(EngineTest, name##_tree_from_events) \
{ \
_RYML_SHOWFILELINE(name); \
SCOPED_TRACE(#name "_tree_from_events"); \
auto const &tc = test_case_##name; \
test_engine_tree_from_events<name>(tc); \
_RYML_SHOWFILELINE(name); \
} \
\
\
\
TEST(EngineTest, name##_testsuite_from_yaml) \
{ \
_RYML_SHOWFILELINE(name); \
SCOPED_TRACE(#name "_testsuite_from_yaml"); \
ReferenceYaml yaml refyaml; \
test_engine_testsuite_from_yaml(yaml, events, opts); \
auto const &tc = test_case_##name; \
test_engine_testsuite_from_yaml(tc, opts); \
_RYML_SHOWFILELINE(name); \
} \
\
@@ -251,8 +424,8 @@ TEST(EngineTest, name##_ints_from_yaml) \
{ \
_RYML_SHOWFILELINE(name); \
SCOPED_TRACE(#name "_event_ints_from_yaml"); \
ReferenceYaml yaml refyaml; \
test_engine_ints_from_yaml(yaml, events, opts); \
auto const &tc = test_case_##name; \
test_engine_ints_from_yaml(tc, opts); \
_RYML_SHOWFILELINE(name); \
} \
\
@@ -260,41 +433,43 @@ TEST(EngineTest, name##_tree_from_yaml) \
{ \
_RYML_SHOWFILELINE(name); \
SCOPED_TRACE(#name "_tree_from_yaml"); \
ReferenceYaml yaml refyaml; \
test_engine_tree_from_yaml(yaml, opts); \
auto const &tc = test_case_##name; \
test_engine_tree_from_yaml(tc, opts); \
_RYML_SHOWFILELINE(name); \
} \
\
\
\
TEST(EngineTest, name##_testsuite_from_yaml_with_comments) \
{ \
_RYML_SHOWFILELINE(name); \
SCOPED_TRACE(#name "_testsuite_from_yaml_with_comments"); \
ReferenceYaml yaml refyaml; \
test_engine_testsuite_from_yaml_with_comments(yaml, events, opts); \
auto const &tc = test_case_##name; \
test_engine_testsuite_from_yaml_with_comments(tc, opts); \
} \
\
TEST(EngineTest, name##_ints_from_yaml_with_comments) \
{ \
_RYML_SHOWFILELINE(name); \
SCOPED_TRACE(#name "_ints_from_yaml_with_comments"); \
ReferenceYaml yaml refyaml; \
test_engine_ints_from_yaml_with_comments(yaml, events, opts); \
auto const &tc = test_case_##name; \
test_engine_ints_from_yaml_with_comments(tc, opts); \
} \
\
TEST(EngineTest, name##_tree_from_yaml_with_comments) \
{ \
_RYML_SHOWFILELINE(name); \
SCOPED_TRACE(#name "_tree_from_yaml"); \
ReferenceYaml yaml refyaml; \
test_engine_tree_from_yaml_with_comments(yaml, opts); \
auto const &tc = test_case_##name; \
test_engine_tree_from_yaml_with_comments(tc, opts); \
_RYML_SHOWFILELINE(name); \
} \
\
\
/* define the function that will produce the \
* sequence of events */ \
template<class Ps> \
void name##_impl(Ps &ps)
template<class EvtHandlerClass> \
void name##_impl(EvtHandlerClass &ps)
@@ -345,9 +520,15 @@ inline C4_NO_INLINE void _print_handler_info(extra::EventHandlerTestSuite const&
inline C4_NO_INLINE void _print_handler_info(extra::EventHandlerInts const& ps, csubstr stmt, const char *file, int line)
{
_dbg_printf("{}:{}: {}", file, line, stmt);
_dbg_printf("{}:{}: {}\n", file, line, stmt);
(void)ps;
}
template<class Handler, class Transformer>
inline C4_NO_INLINE void _print_handler_info(EventTransformer<Handler, Transformer> const& ps, csubstr stmt, const char *file, int line)
{
_print_handler_info(ps.handler, stmt, file, line);
}
#endif
} // namespace yml