blob: 5addf27e13635e00d4e9bb5db3d92bae4fe1f9ea [file] [log] [blame]
Dale Johannesen87a98b52010-11-19 23:23:22 +00001//===- 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
18using namespace llvm;
19
20namespace {
21
22// Unaligned string test.
23TEST(FoldingSetTest, UnalignedStringTest) {
24 SCOPED_TRACE("UnalignedStringTest");
25
26 FoldingSetNodeID a, b;
Ben Craigdfe3d562015-09-04 15:28:13 +000027 // An aligned string.
Dale Johannesen87a98b52010-11-19 23:23:22 +000028 std::string str1= "a test string";
29 a.AddString(str1);
30
Ben Craigdfe3d562015-09-04 15:28:13 +000031 // An unaligned string.
Dale Johannesen87a98b52010-11-19 23:23:22 +000032 std::string str2 = ">" + str1;
33 b.AddString(str2.c_str() + 1);
34
35 EXPECT_EQ(a.ComputeHash(), b.ComputeHash());
36}
37
38}
39