FoldingSet.cpp 930 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. //===- llvm/unittest/ADT/FoldingSetTest.cpp -------------------------------===//
  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. //
  10. // FoldingSet unit tests.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "gtest/gtest.h"
  14. #include "llvm/ADT/FoldingSet.h"
  15. #include <string>
  16. using namespace llvm;
  17. namespace {
  18. // Unaligned string test.
  19. TEST(FoldingSetTest, UnalignedStringTest) {
  20. SCOPED_TRACE("UnalignedStringTest");
  21. FoldingSetNodeID a, b;
  22. // An aligned string
  23. std::string str1= "a test string";
  24. a.AddString(str1);
  25. // An unaligned string
  26. std::string str2 = ">" + str1;
  27. b.AddString(str2.c_str() + 1);
  28. EXPECT_EQ(a.ComputeHash(), b.ComputeHash());
  29. }
  30. }