[llvm-commits] [llvm] r61923 - /llvm/trunk/unittests/ADT/StringMapTest.cpp

Bill Wendling isanbard at gmail.com
Thu Jan 8 01:31:36 PST 2009


Author: void
Date: Thu Jan  8 03:31:36 2009
New Revision: 61923

URL: http://llvm.org/viewvc/llvm-project?rev=61923&view=rev
Log:
Some generic clean-ups. Also make the StringMapEntryInitializer specialization apply only to the tests that are actually testing it.

Modified:
    llvm/trunk/unittests/ADT/StringMapTest.cpp

Modified: llvm/trunk/unittests/ADT/StringMapTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/StringMapTest.cpp?rev=61923&r1=61922&r2=61923&view=diff

==============================================================================
--- llvm/trunk/unittests/ADT/StringMapTest.cpp (original)
+++ llvm/trunk/unittests/ADT/StringMapTest.cpp Thu Jan  8 03:31:36 2009
@@ -11,19 +11,6 @@
 #include "llvm/ADT/StringMap.h"
 using namespace llvm;
 
-namespace llvm {
-
-template <>
-class StringMapEntryInitializer<uint32_t> {
-public:
-  template <typename InitTy>
-  static void Initialize(StringMapEntry<uint32_t> &T, InitTy InitVal) {
-    T.second = InitVal;
-  }
-};
-
-}
-
 namespace {
 
 // Test fixture
@@ -83,13 +70,13 @@
 const char* StringMapTest::testKeyLast = testKey + sizeof(testKey) - 1;
 const std::string StringMapTest::testKeyStr(testKey);
 
-// Empty map tests
+// Empty map tests.
 TEST_F(StringMapTest, EmptyMapTest) {
   SCOPED_TRACE("EmptyMapTest");
   assertEmptyMap();
 }
 
-// Constant map tests
+// Constant map tests.
 TEST_F(StringMapTest, ConstEmptyMapTest) {
   const StringMap<uint32_t>& constTestMap = testMap;
 
@@ -106,18 +93,18 @@
   EXPECT_EQ(0u, constTestMap.count(testKeyStr));
   EXPECT_TRUE(constTestMap.find(testKey) == constTestMap.end());
   EXPECT_TRUE(constTestMap.find(testKeyFirst, testKeyLast) ==
-      constTestMap.end());
+              constTestMap.end());
   EXPECT_TRUE(constTestMap.find(testKeyStr) == constTestMap.end());
 }
 
-// A map with a single entry
+// A map with a single entry.
 TEST_F(StringMapTest, SingleEntryMapTest) {
   SCOPED_TRACE("SingleEntryMapTest");
   testMap[testKey] = testValue;
   assertSingleItemMap();
 }
 
-// Test clear() method
+// Test clear() method.
 TEST_F(StringMapTest, ClearTest) {
   SCOPED_TRACE("ClearTest");
   testMap[testKey] = testValue;
@@ -125,7 +112,7 @@
   assertEmptyMap();
 }
 
-// Test erase(iterator) method
+// Test erase(iterator) method.
 TEST_F(StringMapTest, EraseIteratorTest) {
   SCOPED_TRACE("EraseIteratorTest");
   testMap[testKey] = testValue;
@@ -133,7 +120,7 @@
   assertEmptyMap();
 }
 
-// Test erase(value) method
+// Test erase(value) method.
 TEST_F(StringMapTest, EraseValueTest) {
   SCOPED_TRACE("EraseValueTest");
   testMap[testKey] = testValue;
@@ -141,7 +128,7 @@
   assertEmptyMap();
 }
 
-// Test inserting two values and erasing one
+// Test inserting two values and erasing one.
 TEST_F(StringMapTest, InsertAndEraseTest) {
   SCOPED_TRACE("InsertAndEraseTest");
   testMap[testKey] = testValue;
@@ -150,30 +137,7 @@
   assertSingleItemMap();
 }
 
-// Test StringMapEntry::Create() method.
-// DISABLED because this fails without a StringMapEntryInitializer, and
-// I can't get it to compile with one.
-TEST_F(StringMapTest, StringMapEntryTest) {
-  MallocAllocator A;
-  StringMap<uint32_t>::value_type* entry =
-      StringMap<uint32_t>::value_type::Create(
-          testKeyFirst, testKeyLast, A, 1u);
-  EXPECT_STREQ(testKey, entry->first());
-  EXPECT_EQ(1u, entry->second);
-}
-
-// Test insert() method
-// DISABLED because this fails without a StringMapEntryInitializer, and
-// I can't get it to compile with one.
-TEST_F(StringMapTest, InsertTest) {
-  SCOPED_TRACE("InsertTest");
-  testMap.insert(
-      StringMap<uint32_t>::value_type::Create(
-          testKeyFirst, testKeyLast, testMap.getAllocator(), 1u));
-  assertSingleItemMap();
-}
-
-// A more complex iteration test
+// A more complex iteration test.
 TEST_F(StringMapTest, IterationTest) {
   bool visited[100];
 
@@ -200,4 +164,39 @@
   }
 }
 
+} // end anonymous namespace
+
+namespace llvm {
+
+template <>
+class StringMapEntryInitializer<uint32_t> {
+public:
+  template <typename InitTy>
+  static void Initialize(StringMapEntry<uint32_t> &T, InitTy InitVal) {
+    T.second = InitVal;
+  }
+};
+
+} // end llvm namespace
+
+namespace {
+
+// Test StringMapEntry::Create() method.
+TEST_F(StringMapTest, StringMapEntryTest) {
+  StringMap<uint32_t>::value_type* entry =
+      StringMap<uint32_t>::value_type::Create(
+          testKeyFirst, testKeyLast, 1u);
+  EXPECT_STREQ(testKey, entry->first());
+  EXPECT_EQ(1u, entry->second);
+}
+
+// Test insert() method.
+TEST_F(StringMapTest, InsertTest) {
+  SCOPED_TRACE("InsertTest");
+  testMap.insert(
+      StringMap<uint32_t>::value_type::Create(
+          testKeyFirst, testKeyLast, testMap.getAllocator(), 1u));
+  assertSingleItemMap();
 }
+
+} // end anonymous namespace





More information about the llvm-commits mailing list