Improve build and fix single cr on windows (#1099)

This commit is contained in:
Dr. Andre Vehreschild
2022-04-19 19:39:55 +02:00
committed by GitHub
parent 7d06655611
commit 4c982d59dc
2 changed files with 16 additions and 1 deletions

View File

@@ -37,7 +37,7 @@ inline const RegEx& Blank() {
return e;
}
inline const RegEx& Break() {
static const RegEx e = RegEx('\n') | RegEx("\r");
static const RegEx e = RegEx('\n') | RegEx("\r\n") | RegEx('\r');
return e;
}
inline const RegEx& BlankOrBreak() {

View File

@@ -345,5 +345,20 @@ TEST(NodeTest, LoadTagWithNullScalar) {
EXPECT_TRUE(node.IsNull());
}
TEST(LoadNodeTest, BlockCRNLEncoded) {
Node node = Load(
"blockText: |\r\n"
" some arbitrary text \r\n"
" spanning some \r\n"
" lines, that are split \r\n"
" by CR and NL\r\n"
"followup: 1");
EXPECT_EQ(
"some arbitrary text \nspanning some \nlines, that are split \nby CR and "
"NL\n",
node["blockText"].as<std::string>());
EXPECT_EQ(1, node["followup"].as<int>());
}
} // namespace
} // namespace YAML