diff options
author | Alex Lorenz <arphaman@gmail.com> | 2015-05-21 19:45:02 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2015-05-21 19:45:02 +0000 |
commit | 481dca239365287462520a6c582756280bc742a3 (patch) | |
tree | 0de2cce9e3666f73f90ac4c5777d60241e79f2cc /llvm/unittests/Support/YAMLParserTest.cpp | |
parent | 374929e1917a4164d01cc64ad989893d29adce47 (diff) | |
download | bcm5719-llvm-481dca239365287462520a6c582756280bc742a3.tar.gz bcm5719-llvm-481dca239365287462520a6c582756280bc742a3.zip |
YAML: Null terminate block scalar's value.
The commit null terminates the string value in the `yaml::BlockScalarNode`
class.
This change is motivated by the initial MIR serialization commit (r237708)
that I reverted in r237730 because the LLVM IR source from the block
scalar node wasn't terminated by a null character and thus the buildbots
failed on one testcase sometimes. This change enables me to recommit
the reverted commit.
llvm-svn: 237942
Diffstat (limited to 'llvm/unittests/Support/YAMLParserTest.cpp')
-rw-r--r-- | llvm/unittests/Support/YAMLParserTest.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/unittests/Support/YAMLParserTest.cpp b/llvm/unittests/Support/YAMLParserTest.cpp index d3ee8afeb2d..69b354a91d1 100644 --- a/llvm/unittests/Support/YAMLParserTest.cpp +++ b/llvm/unittests/Support/YAMLParserTest.cpp @@ -157,6 +157,18 @@ TEST(YAMLParser, ParsesBlockLiteralScalars) { ExpectParseError("Long leading space line", "test: |\n \n Test\n"); } +TEST(YAMLParser, NullTerminatedBlockScalars) { + SourceMgr SM; + yaml::Stream Stream("test: |\n Hello\n World\n", SM); + yaml::Document &Doc = *Stream.begin(); + yaml::MappingNode *Map = cast<yaml::MappingNode>(Doc.getRoot()); + StringRef Value = + cast<yaml::BlockScalarNode>(Map->begin()->getValue())->getValue(); + + EXPECT_EQ(Value, "Hello\nWorld\n"); + EXPECT_EQ(Value.data()[Value.size()], '\0'); +} + TEST(YAMLParser, HandlesEndOfFileGracefully) { ExpectParseError("In string starting with EOF", "[\""); ExpectParseError("In string hitting EOF", "[\" "); |