summaryrefslogtreecommitdiff
path: root/unittests/ADT
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-07-23 18:17:34 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-07-23 18:17:34 +0000
commit6316fbcb04af00fe76b6526fab09f51484014b3e (patch)
tree8b18f95c06e96a5e23713880efa491c02372f40c /unittests/ADT
parentb53cc014d0f47b898c9daca34566c16dda6c4c1e (diff)
downloadllvm-6316fbcb04af00fe76b6526fab09f51484014b3e.tar.gz
llvm-6316fbcb04af00fe76b6526fab09f51484014b3e.tar.bz2
llvm-6316fbcb04af00fe76b6526fab09f51484014b3e.tar.xz
Convert StringMap to using StringRef for its APIs.
- Yay for '-'s and simplifications! - I kept StringMap::GetOrCreateValue for compatibility purposes, this can eventually go away. Likewise the StringMapEntry Create functions still follow the old style. - NIFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76888 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ADT')
-rw-r--r--unittests/ADT/StringMapTest.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/unittests/ADT/StringMapTest.cpp b/unittests/ADT/StringMapTest.cpp
index 7bb2391eff..8ee166b5e2 100644
--- a/unittests/ADT/StringMapTest.cpp
+++ b/unittests/ADT/StringMapTest.cpp
@@ -22,7 +22,7 @@ protected:
static const char testKey[];
static const uint32_t testValue;
static const char* testKeyFirst;
- static const char* testKeyLast;
+ static size_t testKeyLength;
static const std::string testKeyStr;
void assertEmptyMap() {
@@ -35,10 +35,11 @@ protected:
// Lookup tests
EXPECT_EQ(0u, testMap.count(testKey));
- EXPECT_EQ(0u, testMap.count(testKeyFirst, testKeyLast));
+ EXPECT_EQ(0u, testMap.count(StringRef(testKeyFirst, testKeyLength)));
EXPECT_EQ(0u, testMap.count(testKeyStr));
EXPECT_TRUE(testMap.find(testKey) == testMap.end());
- EXPECT_TRUE(testMap.find(testKeyFirst, testKeyLast) == testMap.end());
+ EXPECT_TRUE(testMap.find(StringRef(testKeyFirst, testKeyLength)) ==
+ testMap.end());
EXPECT_TRUE(testMap.find(testKeyStr) == testMap.end());
}
@@ -57,10 +58,11 @@ protected:
// Lookup tests
EXPECT_EQ(1u, testMap.count(testKey));
- EXPECT_EQ(1u, testMap.count(testKeyFirst, testKeyLast));
+ EXPECT_EQ(1u, testMap.count(StringRef(testKeyFirst, testKeyLength)));
EXPECT_EQ(1u, testMap.count(testKeyStr));
EXPECT_TRUE(testMap.find(testKey) == testMap.begin());
- EXPECT_TRUE(testMap.find(testKeyFirst, testKeyLast) == testMap.begin());
+ EXPECT_TRUE(testMap.find(StringRef(testKeyFirst, testKeyLength)) ==
+ testMap.begin());
EXPECT_TRUE(testMap.find(testKeyStr) == testMap.begin());
}
};
@@ -68,7 +70,7 @@ protected:
const char StringMapTest::testKey[] = "key";
const uint32_t StringMapTest::testValue = 1u;
const char* StringMapTest::testKeyFirst = testKey;
-const char* StringMapTest::testKeyLast = testKey + sizeof(testKey) - 1;
+size_t StringMapTest::testKeyLength = sizeof(testKey) - 1;
const std::string StringMapTest::testKeyStr(testKey);
// Empty map tests.
@@ -90,10 +92,10 @@ TEST_F(StringMapTest, ConstEmptyMapTest) {
// Lookup tests
EXPECT_EQ(0u, constTestMap.count(testKey));
- EXPECT_EQ(0u, constTestMap.count(testKeyFirst, testKeyLast));
+ EXPECT_EQ(0u, constTestMap.count(StringRef(testKeyFirst, testKeyLength)));
EXPECT_EQ(0u, constTestMap.count(testKeyStr));
EXPECT_TRUE(constTestMap.find(testKey) == constTestMap.end());
- EXPECT_TRUE(constTestMap.find(testKeyFirst, testKeyLast) ==
+ EXPECT_TRUE(constTestMap.find(StringRef(testKeyFirst, testKeyLength)) ==
constTestMap.end());
EXPECT_TRUE(constTestMap.find(testKeyStr) == constTestMap.end());
}
@@ -186,7 +188,7 @@ namespace {
TEST_F(StringMapTest, StringMapEntryTest) {
StringMap<uint32_t>::value_type* entry =
StringMap<uint32_t>::value_type::Create(
- testKeyFirst, testKeyLast, 1u);
+ testKeyFirst, testKeyFirst + testKeyLength, 1u);
EXPECT_STREQ(testKey, entry->first());
EXPECT_EQ(1u, entry->second);
}
@@ -196,7 +198,8 @@ TEST_F(StringMapTest, InsertTest) {
SCOPED_TRACE("InsertTest");
testMap.insert(
StringMap<uint32_t>::value_type::Create(
- testKeyFirst, testKeyLast, testMap.getAllocator(), 1u));
+ testKeyFirst, testKeyFirst + testKeyLength,
+ testMap.getAllocator(), 1u));
assertSingleItemMap();
}