-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] re #205: escaping of special chars in double quoted scalars
- Loading branch information
Showing
5 changed files
with
179 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#ifndef RYML_SINGLE_HEADER | ||
#include <c4/yml/std/std.hpp> | ||
#include <c4/yml/yml.hpp> | ||
#endif | ||
#include <gtest/gtest.h> | ||
|
||
#include "./test_case.hpp" | ||
#include "./test_suite/test_suite_events.hpp" | ||
#include "./test_suite/test_suite_events_emitter.cpp" // HACK | ||
|
||
namespace c4 { | ||
namespace yml { | ||
|
||
void test_evts(csubstr src, std::string expected) | ||
{ | ||
Tree tree = parse_in_arena(src); | ||
auto actual = emit_events<std::string>(tree); | ||
EXPECT_EQ(actual, expected); | ||
} | ||
|
||
TEST(events, docval) | ||
{ | ||
test_evts( | ||
R"('quoted val' | ||
)", | ||
R"(+STR | ||
+DOC | ||
=VAL 'quoted val | ||
-DOC | ||
-STR | ||
)" | ||
); | ||
} | ||
|
||
TEST(events, docsep) | ||
{ | ||
test_evts( | ||
R"(--- 'quoted val' | ||
--- another | ||
... | ||
--- and yet another | ||
... | ||
--- | ||
... | ||
)", | ||
R"(+STR | ||
+DOC | ||
=VAL 'quoted val | ||
-DOC | ||
+DOC | ||
=VAL :another | ||
-DOC | ||
+DOC | ||
=VAL :and yet another | ||
-DOC | ||
+DOC | ||
=VAL : | ||
-DOC | ||
-STR | ||
)" | ||
); | ||
} | ||
|
||
TEST(events, basic_map) | ||
{ | ||
test_evts( | ||
"{foo: bar}", | ||
R"(+STR | ||
+DOC | ||
+MAP | ||
=VAL :foo | ||
=VAL :bar | ||
-MAP | ||
-DOC | ||
-STR | ||
)" | ||
); | ||
} | ||
|
||
TEST(events, basic_seq) | ||
{ | ||
test_evts( | ||
"[foo, bar]", | ||
R"(+STR | ||
+DOC | ||
+SEQ | ||
=VAL :foo | ||
=VAL :bar | ||
-SEQ | ||
-DOC | ||
-STR | ||
)" | ||
); | ||
} | ||
|
||
TEST(events, escapes) | ||
{ | ||
test_evts( | ||
R"("\b\r\n\0\f\/")", | ||
"+STR\n" | ||
"+DOC\n" | ||
"=VAL '\\b\\r\\n\\0\\f/\n" | ||
"-DOC\n" | ||
"-STR\n" | ||
); | ||
} | ||
|
||
|
||
//----------------------------------------------------------------------------- | ||
//----------------------------------------------------------------------------- | ||
//----------------------------------------------------------------------------- | ||
|
||
// The other test executables are written to contain the declarative-style | ||
// YmlTestCases. This executable does not have any but the build setup | ||
// assumes it does, and links with the test lib, which requires an existing | ||
// get_case() function. So this is here to act as placeholder until (if?) | ||
// proper test cases are added here. This was detected in #47 (thanks | ||
// @cburgard). | ||
Case const* get_case(csubstr) | ||
{ | ||
return nullptr; | ||
} | ||
|
||
} // namespace yml | ||
} // namespace c4 |