From: Chandler Carruth Date: Mon, 28 Dec 2015 20:03:16 +0000 (+0000) Subject: [ADT] Don't use a fixture just to get a nonce type for this unittest. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=d0dc794073ee74622a4af86e5553d7926e4b8aec;ds=sidebyside [ADT] Don't use a fixture just to get a nonce type for this unittest. 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 --- diff --git a/unittests/ADT/PointerIntPairTest.cpp b/unittests/ADT/PointerIntPairTest.cpp index 0bbcd9f869e..956c250791e 100644 --- a/unittests/ADT/PointerIntPairTest.cpp +++ b/unittests/ADT/PointerIntPairTest.cpp @@ -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 Pair(this, 1U); - EXPECT_EQ(this, Pair.getPointer()); + PointerIntPair 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 Pair; +TEST(PointerIntPairTest, DefaultInitialize) { + PointerIntPair 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;