Home | History | Annotate | Download | only in ADT
      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 
     14 #include "gtest/gtest.h"
     15 #include "llvm/ADT/FoldingSet.h"
     16 #include <string>
     17 
     18 using namespace llvm;
     19 
     20 namespace {
     21 
     22 // Unaligned string test.
     23 TEST(FoldingSetTest, UnalignedStringTest) {
     24   SCOPED_TRACE("UnalignedStringTest");
     25 
     26   FoldingSetNodeID a, b;
     27   // An aligned string
     28   std::string str1= "a test string";
     29   a.AddString(str1);
     30 
     31   // An unaligned string
     32   std::string str2 = ">" + str1;
     33   b.AddString(str2.c_str() + 1);
     34 
     35   EXPECT_EQ(a.ComputeHash(), b.ComputeHash());
     36 }
     37 
     38 }
     39 
     40