summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ObjectYAML/YAMLTest.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2016-03-01 19:15:06 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2016-03-01 19:15:06 +0000
commitebd9193b57750faabaeed0f28acc23fb38d1d06b (patch)
treec062fc745b317b2eab4a37aa543ea4ac0c5dc649 /llvm/unittests/ObjectYAML/YAMLTest.cpp
parent8a37a988e6644403dc6f0c297d2d653fed3ebdc3 (diff)
downloadbcm5719-llvm-ebd9193b57750faabaeed0f28acc23fb38d1d06b.tar.gz
bcm5719-llvm-ebd9193b57750faabaeed0f28acc23fb38d1d06b.zip
Move ObjectYAML code to a new library.
It is only ever used by obj2yaml and yaml2obj. No point in linking it everywhere. llvm-svn: 262368
Diffstat (limited to 'llvm/unittests/ObjectYAML/YAMLTest.cpp')
-rw-r--r--llvm/unittests/ObjectYAML/YAMLTest.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/llvm/unittests/ObjectYAML/YAMLTest.cpp b/llvm/unittests/ObjectYAML/YAMLTest.cpp
new file mode 100644
index 00000000000..606e160d19a
--- /dev/null
+++ b/llvm/unittests/ObjectYAML/YAMLTest.cpp
@@ -0,0 +1,38 @@
+//===- YAMLTest.cpp - Tests for Object YAML -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ObjectYAML/YAML.h"
+#include "llvm/Support/YAMLTraits.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+struct BinaryHolder {
+ yaml::BinaryRef Binary;
+};
+
+namespace llvm {
+namespace yaml {
+template <>
+struct MappingTraits<BinaryHolder> {
+ static void mapping(IO &IO, BinaryHolder &BH) {
+ IO.mapRequired("Binary", BH.Binary);
+ }
+};
+} // end namespace yaml
+} // end namespace llvm
+
+TEST(ObjectYAML, BinaryRef) {
+ BinaryHolder BH;
+ SmallVector<char, 32> Buf;
+ llvm::raw_svector_ostream OS(Buf);
+ yaml::Output YOut(OS);
+ YOut << BH;
+ EXPECT_NE(OS.str().find("''"), StringRef::npos);
+}
OpenPOWER on IntegriCloud