aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support
diff options
context:
space:
mode:
authorCongcong Cai <congcongcai0907@163.com>2025-03-25 23:34:12 +0800
committerGitHub <noreply@github.com>2025-03-25 23:34:12 +0800
commitfeecb201ab041dbcf8266960aba4b252a789bcd4 (patch)
tree89b81aaeb19f0a8509ef07653f7efb75e52ae33e /llvm/unittests/Support
parentf3a14217a995e5b086dea3677edb43e48e6b1af2 (diff)
downloadllvm-feecb201ab041dbcf8266960aba4b252a789bcd4.zip
llvm-feecb201ab041dbcf8266960aba4b252a789bcd4.tar.gz
llvm-feecb201ab041dbcf8266960aba4b252a789bcd4.tar.bz2
Reapply "[YAML][NFC] precommit wrong test case (#131782)" (#132936)
This reverts commit 64779455b8f4875c7de690dd4c3e324dbbcb3029.
Diffstat (limited to 'llvm/unittests/Support')
-rw-r--r--llvm/unittests/Support/YAMLIOTest.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/unittests/Support/YAMLIOTest.cpp b/llvm/unittests/Support/YAMLIOTest.cpp
index c0e9c57..f03563c 100644
--- a/llvm/unittests/Support/YAMLIOTest.cpp
+++ b/llvm/unittests/Support/YAMLIOTest.cpp
@@ -1273,6 +1273,36 @@ TEST(YAMLIO, TestReadWriteBlockScalarValue) {
}
}
+struct V {
+ MultilineStringType doc;
+ std::string str;
+};
+template <> struct llvm::yaml::MappingTraits<V> {
+ static void mapping(IO &io, V &v) {
+ io.mapRequired("block_scalac", v.doc);
+ io.mapRequired("scalar", v.str);
+ }
+};
+template <> struct llvm::yaml::SequenceElementTraits<V> {
+ static const bool flow = false;
+};
+TEST(YAMLIO, TestScalarAfterBlockScalar) {
+ std::vector<V> v{V{}};
+ v[0].doc.str = "AA\nBB";
+ v[0].str = "a";
+ std::string output;
+ llvm::raw_string_ostream ostr(output);
+ Output yout(ostr);
+ yout << v;
+ EXPECT_EQ(output, R"(---
+- block_scalac: |
+ AA
+ BB
+scalar: a
+...
+)");
+}
+
//===----------------------------------------------------------------------===//
// Test flow sequences
//===----------------------------------------------------------------------===//