3428e94d64dc965ee96d689b2812fdde7d244ce9
[oota-llvm.git] / YAMLTest.cpp
1 //===- llvm/unittest/Object/YAMLTest.cpp - Tests for Object YAML ----------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "llvm/Object/YAML.h"
11 #include "llvm/Support/YAMLTraits.h"
12 #include "gtest/gtest.h"
13
14 using namespace llvm;
15
16 namespace {
17 struct BinaryHolder {
18   object::yaml::BinaryRef Binary;
19 };
20 } // end anonymous namespace
21
22 namespace llvm {
23 namespace yaml {
24 template <>
25 struct MappingTraits<BinaryHolder> {
26   static void mapping(IO &IO, BinaryHolder &BH) {
27     IO.mapRequired("Binary", BH.Binary);
28   }
29 };
30 } // end namespace yaml
31 } // end namespace llvm
32
33 TEST(ObjectYAML, BinaryRef) {
34   BinaryHolder BH;
35   SmallVector<char, 32> Buf;
36   llvm::raw_svector_ostream OS(Buf);
37   yaml::Output YOut(OS);
38   YOut << BH;
39   EXPECT_NE(OS.str().find("\"\""), StringRef::npos);
40 }