Rafael Espindola | 18903ff | 2016-03-01 19:15:06 +0000 | [diff] [blame] | 1 | //===- YAMLTest.cpp - Tests for Object YAML -------------------------------===// |
Sean Silva | 845e196 | 2013-07-09 00:54:46 +0000 | [diff] [blame] | 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 Espindola | 18903ff | 2016-03-01 19:15:06 +0000 | [diff] [blame] | 10 | #include "llvm/ObjectYAML/YAML.h" |
Sean Silva | 845e196 | 2013-07-09 00:54:46 +0000 | [diff] [blame] | 11 | #include "llvm/Support/YAMLTraits.h" |
| 12 | #include "gtest/gtest.h" |
| 13 | |
| 14 | using namespace llvm; |
| 15 | |
Sean Silva | 845e196 | 2013-07-09 00:54:46 +0000 | [diff] [blame] | 16 | struct BinaryHolder { |
Rafael Espindola | 7413fef | 2014-07-03 02:01:39 +0000 | [diff] [blame] | 17 | yaml::BinaryRef Binary; |
Sean Silva | 845e196 | 2013-07-09 00:54:46 +0000 | [diff] [blame] | 18 | }; |
Sean Silva | 845e196 | 2013-07-09 00:54:46 +0000 | [diff] [blame] | 19 | |
| 20 | namespace llvm { |
| 21 | namespace yaml { |
| 22 | template <> |
| 23 | struct 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 | |
| 31 | TEST(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 Majnemer | 8bd2799 | 2014-03-20 06:28:52 +0000 | [diff] [blame] | 37 | EXPECT_NE(OS.str().find("''"), StringRef::npos); |
Sean Silva | 845e196 | 2013-07-09 00:54:46 +0000 | [diff] [blame] | 38 | } |