#include "base/memory/ref_counted.h"
#include <type_traits>
#include <utility>
#include "base/memory/raw_ptr.h"
#include "base/test/gtest_util.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
namespace subtle {
namespace {
class SelfAssign : public base::RefCounted<SelfAssign> { … };
class Derived : public SelfAssign { … };
class CheckDerivedMemberAccess : public scoped_refptr<SelfAssign> { … };
class ScopedRefPtrToSelf : public base::RefCounted<ScopedRefPtrToSelf> { … };
bool ScopedRefPtrToSelf::was_destroyed_ = …;
class ScopedRefPtrCountBase : public base::RefCounted<ScopedRefPtrCountBase> { … };
int ScopedRefPtrCountBase::constructor_count_ = …;
int ScopedRefPtrCountBase::destructor_count_ = …;
class ScopedRefPtrCountDerived : public ScopedRefPtrCountBase { … };
int ScopedRefPtrCountDerived::constructor_count_ = …;
int ScopedRefPtrCountDerived::destructor_count_ = …;
class Other : public base::RefCounted<Other> { … };
class HasPrivateDestructorWithDeleter;
struct Deleter { … };
class HasPrivateDestructorWithDeleter
: public base::RefCounted<HasPrivateDestructorWithDeleter, Deleter> { … };
void Deleter::Destruct(const HasPrivateDestructorWithDeleter* x) { … }
scoped_refptr<Other> Overloaded(scoped_refptr<Other> other) { … }
scoped_refptr<SelfAssign> Overloaded(scoped_refptr<SelfAssign> self_assign) { … }
class InitialRefCountIsOne : public base::RefCounted<InitialRefCountIsOne> { … };
class CheckRefptrNull : public base::RefCounted<CheckRefptrNull> { … };
}
TEST(RefCountedUnitTest, TestSelfAssignment) { … }
TEST(RefCountedUnitTest, ScopedRefPtrMemberAccess) { … }
TEST(RefCountedUnitTest, ScopedRefPtrToSelfPointerAssignment) { … }
TEST(RefCountedUnitTest, ScopedRefPtrToSelfMoveAssignment) { … }
TEST(RefCountedUnitTest, BooleanTesting) { … }
TEST(RefCountedUnitTest, Equality) { … }
TEST(RefCountedUnitTest, Ordering) { … }
TEST(RefCountedUnitTest, NullptrEquality) { … }
TEST(RefCountedUnitTest, NullptrOrdering) { … }
TEST(RefCountedUnitTest, ConvertibleEquality) { … }
TEST(RefCountedUnitTest, MoveAssignment1) { … }
TEST(RefCountedUnitTest, MoveAssignment2) { … }
TEST(RefCountedUnitTest, MoveAssignmentSameInstance1) { … }
TEST(RefCountedUnitTest, MoveAssignmentSameInstance2) { … }
TEST(RefCountedUnitTest, MoveAssignmentDifferentInstances) { … }
TEST(RefCountedUnitTest, MoveAssignmentSelfMove) { … }
TEST(RefCountedUnitTest, MoveAssignmentDerived) { … }
TEST(RefCountedUnitTest, MoveConstructor) { … }
TEST(RefCountedUnitTest, MoveConstructorDerived) { … }
TEST(RefCountedUnitTest, TestOverloadResolutionCopy) { … }
TEST(RefCountedUnitTest, TestOverloadResolutionMove) { … }
TEST(RefCountedUnitTest, TestMakeRefCounted) { … }
TEST(RefCountedUnitTest, TestInitialRefCountIsOne) { … }
TEST(RefCountedUnitTest, TestPrivateDestructorWithDeleter) { … }
TEST(RefCountedUnitTest, TestReset) { … }
TEST(RefCountedUnitTest, TestResetAlreadyNull) { … }
TEST(RefCountedUnitTest, TestResetByNullptrAssignment) { … }
TEST(RefCountedUnitTest, CheckScopedRefptrNullBeforeObjectDestruction) { … }
TEST(RefCountedDeathTest, TestAdoptRef) { … }
#if defined(ARCH_CPU_64_BITS)
class RefCountedOverflowTest : public ::testing::Test { … };
TEST_F(RefCountedOverflowTest, NonThreadSafeStartFromZero) { … }
TEST_F(RefCountedOverflowTest, NonThreadSafeStartFromOne) { … }
TEST_F(RefCountedOverflowTest, ThreadSafeStartFromZero) { … }
TEST_F(RefCountedOverflowTest, ThreadSafeStartFromOne) { … }
#endif
}
}