blob: 09709ad73fc7ceb10f80aa57d7aefcdf7d1b677b [file] [log] [blame]
Sean Silva2f672d62013-07-09 00:54:46 +00001//===- 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
Rafael Espindola97de4742014-07-03 02:01:39 +000010#include "llvm/MC/YAML.h"
Sean Silva2f672d62013-07-09 00:54:46 +000011#include "llvm/Support/YAMLTraits.h"
12#include "gtest/gtest.h"
13
14using namespace llvm;
15
Sean Silva2f672d62013-07-09 00:54:46 +000016struct BinaryHolder {
Rafael Espindola97de4742014-07-03 02:01:39 +000017 yaml::BinaryRef Binary;
Sean Silva2f672d62013-07-09 00:54:46 +000018};
Sean Silva2f672d62013-07-09 00:54:46 +000019
20namespace llvm {
21namespace yaml {
22template <>
23struct MappingTraits<BinaryHolder> {
24 static void mapping(IO &IO, BinaryHolder &BH) {
25 IO.mapRequired("Binary", BH.Binary);
26 }
27};
28} // end namespace yaml
29} // end namespace llvm
30
31TEST(ObjectYAML, BinaryRef) {
32 BinaryHolder BH;
33 SmallVector<char, 32> Buf;
34 llvm::raw_svector_ostream OS(Buf);
35 yaml::Output YOut(OS);
36 YOut << BH;
David Majnemerd9eb2d12014-03-20 06:28:52 +000037 EXPECT_NE(OS.str().find("''"), StringRef::npos);
Sean Silva2f672d62013-07-09 00:54:46 +000038}