Reapply "[YAML][NFC] precommit wrong test case (#131782)" (#132936)

This reverts commit 64779455b8f4875c7de690dd4c3e324dbbcb3029.
This commit is contained in:
Congcong Cai 2025-03-25 23:34:12 +08:00 committed by GitHub
parent f3a14217a9
commit feecb201ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
//===----------------------------------------------------------------------===//