[yaml2obj/obj2yaml] - Add support for .stack_sizes sections.
[llvm-complete.git] / unittests / ObjectYAML / YAMLTest.cpp
blob3d283a03b22567b2894169d227449446559cd6ac
1 //===- YAMLTest.cpp - Tests for Object YAML -------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ObjectYAML/YAML.h"
10 #include "llvm/Support/YAMLTraits.h"
11 #include "gtest/gtest.h"
13 using namespace llvm;
15 struct BinaryHolder {
16 yaml::BinaryRef Binary;
19 namespace llvm {
20 namespace yaml {
21 template <>
22 struct MappingTraits<BinaryHolder> {
23 static void mapping(IO &IO, BinaryHolder &BH) {
24 IO.mapRequired("Binary", BH.Binary);
27 } // end namespace yaml
28 } // end namespace llvm
30 TEST(ObjectYAML, BinaryRef) {
31 BinaryHolder BH;
32 SmallVector<char, 32> Buf;
33 llvm::raw_svector_ostream OS(Buf);
34 yaml::Output YOut(OS);
35 YOut << BH;
36 EXPECT_NE(OS.str().find("''"), StringRef::npos);