YAMLTest.cpp 979 B

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