From 8a859768d9cac77985b8affa478d2cdca90931be Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Tue, 18 Mar 2025 10:55:55 +0000 Subject: [PATCH] [YAML][NFC] precommit wrong test case --- llvm/unittests/Support/YAMLIOTest.cpp | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/llvm/unittests/Support/YAMLIOTest.cpp b/llvm/unittests/Support/YAMLIOTest.cpp index c0e9c57a77f19..3db1db57ad596 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 MappingTraits { + static void mapping(IO &io, V &v) { + io.mapRequired("block_scalac", v.doc); + io.mapRequired("scalar", v.str); + } +}; +template <> struct llvm::yaml::SequenceElementTraits { + static const bool flow = false; +}; +TEST(YAMLIO, TestScalarAfterBlockScalar) { + std::vector 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 //===----------------------------------------------------------------------===//