[ADT] Don't use a fixture just to get a nonce type for this unittest.
authorChandler Carruth <chandlerc@gmail.com>
Mon, 28 Dec 2015 20:03:16 +0000 (20:03 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Mon, 28 Dec 2015 20:03:16 +0000 (20:03 +0000)
Instead, actually produce a nonce type in the test and use that. This
makes the test, IMO, both simpler and more clear.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256518 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/ADT/PointerIntPairTest.cpp

index 0bbcd9f869eca9a2bd24af0badbdf26448f492b0..956c250791ec82cbfc4d679b01f893db152cc031 100644 (file)
@@ -14,35 +14,35 @@ using namespace llvm;
 
 namespace {
 
-// Test fixture
-class PointerIntPairTest : public testing::Test {
-};
+TEST(PointerIntPairTest, GetSet) {
+  struct S {
+  };
+  S s;
 
-TEST_F(PointerIntPairTest, GetSet) {
-  PointerIntPair<PointerIntPairTest *, 2> Pair(this, 1U);
-  EXPECT_EQ(this, Pair.getPointer());
+  PointerIntPair<S *, 2> Pair(&s, 1U);
+  EXPECT_EQ(&s, Pair.getPointer());
   EXPECT_EQ(1U, Pair.getInt());
 
   Pair.setInt(2);
-  EXPECT_EQ(this, Pair.getPointer());
+  EXPECT_EQ(&s, Pair.getPointer());
   EXPECT_EQ(2U, Pair.getInt());
 
   Pair.setPointer(nullptr);
   EXPECT_EQ(nullptr, Pair.getPointer());
   EXPECT_EQ(2U, Pair.getInt());
 
-  Pair.setPointerAndInt(this, 3U);
-  EXPECT_EQ(this, Pair.getPointer());
+  Pair.setPointerAndInt(&s, 3U);
+  EXPECT_EQ(&s, Pair.getPointer());
   EXPECT_EQ(3U, Pair.getInt());
 }
 
-TEST_F(PointerIntPairTest, DefaultInitialize) {
-  PointerIntPair<PointerIntPairTest *, 2> Pair;
+TEST(PointerIntPairTest, DefaultInitialize) {
+  PointerIntPair<float *, 2> Pair;
   EXPECT_EQ(nullptr, Pair.getPointer());
   EXPECT_EQ(0U, Pair.getInt());
 }
 
-TEST_F(PointerIntPairTest, ManyUnusedBits) {
+TEST(PointerIntPairTest, ManyUnusedBits) {
   // In real code this would be a word-sized integer limited to 31 bits.
   struct Fixnum31 {
     uintptr_t Value;