YAMLTest.cpp 943 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. #include "llvm/MC/YAML.h"
  10. #include "llvm/Support/YAMLTraits.h"
  11. #include "gtest/gtest.h"
  12. using namespace llvm;
  13. struct BinaryHolder {
  14. yaml::BinaryRef Binary;
  15. };
  16. namespace llvm {
  17. namespace yaml {
  18. template <>
  19. struct MappingTraits<BinaryHolder> {
  20. static void mapping(IO &IO, BinaryHolder &BH) {
  21. IO.mapRequired("Binary", BH.Binary);
  22. }
  23. };
  24. } // end namespace yaml
  25. } // end namespace llvm
  26. TEST(ObjectYAML, BinaryRef) {
  27. BinaryHolder BH;
  28. SmallVector<char, 32> Buf;
  29. llvm::raw_svector_ostream OS(Buf);
  30. yaml::Output YOut(OS);
  31. YOut << BH;
  32. EXPECT_NE(OS.str().find("''"), StringRef::npos);
  33. }