summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/FoldingSet.cpp
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2010-11-19 23:23:22 +0000
committerDale Johannesen <dalej@apple.com>2010-11-19 23:23:22 +0000
commit87a98b57b815192c9895de636d0afe3e3a963c72 (patch)
treef3eab671ca470caddfcc3166a71ee83007a99227 /llvm/unittests/ADT/FoldingSet.cpp
parent2aff392af97b20fa8fe195643ffb9f4c11351150 (diff)
downloadbcm5719-llvm-87a98b57b815192c9895de636d0afe3e3a963c72.tar.gz
bcm5719-llvm-87a98b57b815192c9895de636d0afe3e3a963c72.zip
Add test for PR 8111. By Frits van Bommel.
llvm-svn: 119870
Diffstat (limited to 'llvm/unittests/ADT/FoldingSet.cpp')
-rw-r--r--llvm/unittests/ADT/FoldingSet.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/FoldingSet.cpp b/llvm/unittests/ADT/FoldingSet.cpp
new file mode 100644
index 00000000000..a18a0df9571
--- /dev/null
+++ b/llvm/unittests/ADT/FoldingSet.cpp
@@ -0,0 +1,39 @@
+//===- llvm/unittest/ADT/FoldingSetTest.cpp -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// FoldingSet unit tests.
+//
+//===----------------------------------------------------------------------===//
+
+#include "gtest/gtest.h"
+#include "llvm/ADT/FoldingSet.h"
+#include <string>
+
+using namespace llvm;
+
+namespace {
+
+// Unaligned string test.
+TEST(FoldingSetTest, UnalignedStringTest) {
+ SCOPED_TRACE("UnalignedStringTest");
+
+ FoldingSetNodeID a, b;
+ // An aligned string
+ std::string str1= "a test string";
+ a.AddString(str1);
+
+ // An unaligned string
+ std::string str2 = ">" + str1;
+ b.AddString(str2.c_str() + 1);
+
+ EXPECT_EQ(a.ComputeHash(), b.ComputeHash());
+}
+
+}
+
OpenPOWER on IntegriCloud