Changeset View
Changeset View
Standalone View
Standalone View
llvm/unittests/ADT/IntrusiveRefCntPtrTest.cpp
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | EXPECT_EQ(0, NumInstances); | ||||
auto S1 = std::make_unique<TypeParam>(); | auto S1 = std::make_unique<TypeParam>(); | ||||
IntrusiveRefCntPtr<TypeParam> R1 = std::move(S1); | IntrusiveRefCntPtr<TypeParam> R1 = std::move(S1); | ||||
EXPECT_EQ(1, NumInstances); | EXPECT_EQ(1, NumInstances); | ||||
EXPECT_EQ(S1, nullptr); | EXPECT_EQ(S1, nullptr); | ||||
} | } | ||||
EXPECT_EQ(0, NumInstances); | EXPECT_EQ(0, NumInstances); | ||||
} | } | ||||
TYPED_TEST(IntrusiveRefCntPtrTest, MakeIntrusiveRefCnt) { | |||||
EXPECT_EQ(0, NumInstances); | |||||
{ | |||||
auto S1 = makeIntrusiveRefCnt<TypeParam>(); | |||||
auto S2 = makeIntrusiveRefCnt<const TypeParam>(); | |||||
EXPECT_EQ(2, NumInstances); | |||||
static_assert( | |||||
std::is_same<decltype(S1), IntrusiveRefCntPtr<TypeParam>>::value, | |||||
"Non-const type mismatch"); | |||||
static_assert( | |||||
std::is_same<decltype(S2), IntrusiveRefCntPtr<const TypeParam>>::value, | |||||
"Const type mismatch"); | |||||
njames93: Couldn't think how best to test this, but these seem to do a good enough job. | |||||
} | |||||
EXPECT_EQ(0, NumInstances); | |||||
} | |||||
struct InterceptRefCounted : public RefCountedBase<InterceptRefCounted> { | struct InterceptRefCounted : public RefCountedBase<InterceptRefCounted> { | ||||
InterceptRefCounted(bool *Released, bool *Retained) | InterceptRefCounted(bool *Released, bool *Retained) | ||||
: Released(Released), Retained(Retained) {} | : Released(Released), Retained(Retained) {} | ||||
bool * const Released; | bool * const Released; | ||||
bool * const Retained; | bool * const Retained; | ||||
}; | }; | ||||
template <> struct IntrusiveRefCntPtrInfo<InterceptRefCounted> { | template <> struct IntrusiveRefCntPtrInfo<InterceptRefCounted> { | ||||
static void retain(InterceptRefCounted *I) { | static void retain(InterceptRefCounted *I) { | ||||
Show All 20 Lines |
Couldn't think how best to test this, but these seem to do a good enough job.