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 //===----------------------------------------------------------------------===// 8 9 #include "llvm/ObjectYAML/YAML.h" 10 #include "llvm/Support/YAMLTraits.h" 11 #include "gtest/gtest.h" 12 13 using namespace llvm; 14 15 struct BinaryHolder { 16 yaml::BinaryRef Binary; 17 }; 18 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); 25 } 26 }; 27 } // end namespace yaml 28 } // end namespace llvm 29 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); 37 } 38