Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions llvm/unittests/Support/YAMLIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,36 @@ TEST(YAMLIO, TestReadWriteBlockScalarValue) {
}
}

struct V {
MultilineStringType doc;
std::string str;
};
template <> struct 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
//===----------------------------------------------------------------------===//
Expand Down