Rename unique_ref::isValid to is_valid to comply with naming scheme of other functions

This commit is contained in:
Sebastian Messmer 2017-04-10 14:16:30 -07:00
parent 6f0f5c037a
commit 317088e449
5 changed files with 27 additions and 27 deletions

View File

@ -13,7 +13,7 @@ CachedBlock::CachedBlock(unique_ref<Block> baseBlock, CachingBlockStore *blockSt
}
CachedBlock::~CachedBlock() {
if (_baseBlock.isValid()) {
if (_baseBlock.is_valid()) {
_blockStore->release(std::move(_baseBlock));
}
}

View File

@ -85,7 +85,7 @@ public:
std::swap(_target, rhs._target);
}
bool isValid() const noexcept {
bool is_valid() const noexcept {
return _target.get() != nullptr;
}

View File

@ -5,10 +5,10 @@ namespace cryfs {
namespace cachingfsblobstore {
FsBlobRef::~FsBlobRef() {
if (_baseBlob.isValid()) {
if (_baseBlob.is_valid()) {
_fsBlobStore->releaseForCache(std::move(_baseBlob));
}
}
}
}
}

View File

@ -67,7 +67,7 @@ TEST(UniqueRef_DynamicPointerMoveTest, ValidParentToChildCast) {
Child *obj = new Child();
unique_ref<Parent> source(nullcheck(unique_ptr<Parent>(obj)).value());
unique_ref<Child> casted = dynamic_pointer_move<Child>(source).value();
EXPECT_FALSE(source.isValid()); // source lost ownership
EXPECT_FALSE(source.is_valid()); // source lost ownership
EXPECT_EQ(obj, casted.get());
}
@ -115,7 +115,7 @@ TEST(UniqueRef_DynamicPointerMoveTest, ChildToParentCast) {
Child *obj = new Child();
unique_ref<Child> source(nullcheck(unique_ptr<Child>(obj)).value());
unique_ref<Parent> casted = dynamic_pointer_move<Parent>(source).value();
EXPECT_FALSE(source.isValid()); // source lost ownership
EXPECT_FALSE(source.is_valid()); // source lost ownership
EXPECT_EQ(obj, casted.get());
}

View File

@ -190,7 +190,7 @@ TEST_F(UniqueRefTest, givenUniqueRef_whenMoveAssigning_thenOldInstanceInvalid) {
unique_ref<SomeClass> obj1 = make_unique_ref<SomeClass>();
unique_ref<SomeClass> obj2 = make_unique_ref<SomeClass>();
obj2 = std::move(obj1);
EXPECT_FALSE(obj1.isValid());
EXPECT_FALSE(obj1.is_valid());
}
TEST_F(UniqueRefTest, givenUniqueRef_whenMoveAssigningToBaseClass_thenPointsToSameObject) {
@ -204,7 +204,7 @@ TEST_F(UniqueRefTest, givenUniqueRef_whenMoveAssigningToBaseClass_thenOldInstanc
unique_ref<SomeChildClass> obj1 = make_unique_ref<SomeChildClass>(3);
unique_ref<SomeBaseClass> obj2 = make_unique_ref<SomeBaseClass>(10);
obj2 = std::move(obj1);
EXPECT_FALSE(obj1.isValid());
EXPECT_FALSE(obj1.is_valid());
}
TEST_F(UniqueRefTest, givenUniqueRef_whenMoveAssigningToUniquePtr_thenPointsToSameObject) {
@ -219,7 +219,7 @@ TEST_F(UniqueRefTest, givenUniqueRef_whenMoveAssigningToUniquePtr_thenOldInstanc
unique_ref<SomeClass> obj1 = make_unique_ref<SomeClass>();
std::unique_ptr<SomeClass> obj2 = std::make_unique<SomeClass>();
obj2 = std::move(obj1);
EXPECT_FALSE(obj1.isValid());
EXPECT_FALSE(obj1.is_valid());
}
TEST_F(UniqueRefTest, givenUniqueRef_whenMoveAssigningToBaseClassUniquePtr_thenPointsToSameObject) {
@ -233,7 +233,7 @@ TEST_F(UniqueRefTest, givenUniqueRef_whenMoveAssigningToBaseClassUniquePtr_thenO
unique_ref<SomeChildClass> obj1 = make_unique_ref<SomeChildClass>(3);
std::unique_ptr<SomeBaseClass> obj2 = std::make_unique<SomeBaseClass>(10);
obj2 = std::move(obj1);
EXPECT_FALSE(obj1.isValid());
EXPECT_FALSE(obj1.is_valid());
}
TEST_F(UniqueRefTest, givenUniqueRef_whenMoveAssigningToSharedPtr_thenPointsToSameObject) {
@ -248,7 +248,7 @@ TEST_F(UniqueRefTest, givenUniqueRef_whenMoveAssigningToSharedPtr_thenOldInstanc
unique_ref<SomeClass> obj1 = make_unique_ref<SomeClass>();
std::shared_ptr<SomeClass> obj2 = std::make_shared<SomeClass>();
obj2 = std::move(obj1);
EXPECT_FALSE(obj1.isValid());
EXPECT_FALSE(obj1.is_valid());
}
TEST_F(UniqueRefTest, givenUniqueRef_whenMoveAssigningToBaseClassSharedPtr_thenPointsToSameObject) {
@ -262,7 +262,7 @@ TEST_F(UniqueRefTest, givenUniqueRef_whenMoveAssigningToBaseClassSharedPtr_thenO
unique_ref<SomeChildClass> obj1 = make_unique_ref<SomeChildClass>(3);
std::shared_ptr<SomeBaseClass> obj2 = std::make_shared<SomeBaseClass>(10);
obj2 = std::move(obj1);
EXPECT_FALSE(obj1.isValid());
EXPECT_FALSE(obj1.is_valid());
}
TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructing_thenPointsToSameObject) {
@ -275,7 +275,7 @@ TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructing_thenPointsToSameObject
TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructing_thenOldInstanceInvalid) {
unique_ref<SomeClass> obj1 = make_unique_ref<SomeClass>();
unique_ref<SomeClass> obj2 = std::move(obj1);
EXPECT_FALSE(obj1.isValid());
EXPECT_FALSE(obj1.is_valid());
}
TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructingToBaseClass_thenPointsToSameObject) {
@ -287,7 +287,7 @@ TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructingToBaseClass_thenPointsT
TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructingToBaseClass_thenOldInstanceInvalid) {
unique_ref<SomeChildClass> child = make_unique_ref<SomeChildClass>(3);
unique_ref<SomeBaseClass> base = std::move(child);
EXPECT_FALSE(child.isValid());
EXPECT_FALSE(child.is_valid());
}
TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructingToUniquePtr_thenPointsToSameObject) {
@ -300,7 +300,7 @@ TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructingToUniquePtr_thenPointsT
TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructingToUniquePtr_thenOldInstanceInvalid) {
unique_ref<SomeClass> obj1 = make_unique_ref<SomeClass>();
std::unique_ptr<SomeClass> obj2 = std::move(obj1);
EXPECT_FALSE(obj1.isValid());
EXPECT_FALSE(obj1.is_valid());
}
TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructingToBaseClassUniquePtr_thenPointsToSameObject) {
@ -312,7 +312,7 @@ TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructingToBaseClassUniquePtr_th
TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructingToBaseClassUniquePtr_thenOldInstanceInvalid) {
unique_ref<SomeChildClass> child = make_unique_ref<SomeChildClass>(3);
std::unique_ptr<SomeBaseClass> base = std::move(child);
EXPECT_FALSE(child.isValid());
EXPECT_FALSE(child.is_valid());
}
TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructingToSharedPtr_thenPointsToSameObject) {
@ -325,7 +325,7 @@ TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructingToSharedPtr_thenPointsT
TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructingToSharedPtr_thenOldInstanceInvalid) {
unique_ref<SomeClass> obj1 = make_unique_ref<SomeClass>();
std::shared_ptr<SomeClass> obj2 = std::move(obj1);
EXPECT_FALSE(obj1.isValid());
EXPECT_FALSE(obj1.is_valid());
}
TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructingToBaseClassSharedPtr_thenPointsToSameObject) {
@ -337,7 +337,7 @@ TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructingToBaseClassSharedPtr_th
TEST_F(UniqueRefTest, givenUniqueRef_whenMoveConstructingToBaseClassSharedPtr_thenOldInstanceInvalid) {
unique_ref<SomeChildClass> child = make_unique_ref<SomeChildClass>(3);
std::shared_ptr<SomeBaseClass> base = std::move(child);
EXPECT_FALSE(child.isValid());
EXPECT_FALSE(child.is_valid());
}
TEST_F(UniqueRefTest, Swap) {
@ -357,8 +357,8 @@ TEST_F(UniqueRefTest, SwapFromInvalid) {
SomeClass *obj2ptr = obj2.get();
std::swap(obj1, obj2);
EXPECT_EQ(obj2ptr, obj1.get());
EXPECT_TRUE(obj1.isValid());
EXPECT_FALSE(obj2.isValid());
EXPECT_TRUE(obj1.is_valid());
EXPECT_FALSE(obj2.is_valid());
}
TEST_F(UniqueRefTest, SwapWithInvalid) {
@ -367,8 +367,8 @@ TEST_F(UniqueRefTest, SwapWithInvalid) {
makeInvalid(std::move(obj2));
SomeClass *obj1ptr = obj1.get();
std::swap(obj1, obj2);
EXPECT_FALSE(obj1.isValid());
EXPECT_TRUE(obj2.isValid());
EXPECT_FALSE(obj1.is_valid());
EXPECT_TRUE(obj2.is_valid());
EXPECT_EQ(obj1ptr, obj2.get());
}
@ -378,8 +378,8 @@ TEST_F(UniqueRefTest, SwapInvalidWithInvalid) {
makeInvalid(std::move(obj1));
makeInvalid(std::move(obj2));
std::swap(obj1, obj2);
EXPECT_FALSE(obj1.isValid());
EXPECT_FALSE(obj2.isValid());
EXPECT_FALSE(obj1.is_valid());
EXPECT_FALSE(obj2.is_valid());
}
TEST_F(UniqueRefTest, SwapFromRValue) {
@ -656,7 +656,7 @@ TEST_F(UniqueRefTest, givenUniqueRefWithDefaultDeleter_whenDestructCalled_thenCa
auto obj = make_unique_ref<DestructableMock>(&wasDestructed);
destruct(std::move(obj));
EXPECT_TRUE(wasDestructed);
EXPECT_FALSE(obj.isValid());
EXPECT_FALSE(obj.is_valid());
}
namespace {
@ -703,7 +703,7 @@ TEST_F(UniqueRefTest, givenUniqueRefWithCustomDefaultConstructibleDeleter_whenDe
auto obj = nullcheck(std::unique_ptr<bool, SetToTrueDeleter>(&wasDestructed)).value();
destruct(std::move(obj));
EXPECT_TRUE(wasDestructed);
EXPECT_FALSE(obj.isValid());
EXPECT_FALSE(obj.is_valid());
}
namespace {
@ -753,7 +753,7 @@ TEST_F(UniqueRefTest, givenUniqueRefWithCustomDeleterInstance_whenDestructCalled
auto obj = nullcheck(std::unique_ptr<int, SetToDeleter>(&value, SetToDeleter(4))).value();
destruct(std::move(obj));
EXPECT_EQ(4, value);
EXPECT_FALSE(obj.isValid());
EXPECT_FALSE(obj.is_valid());
}
TEST_F(UniqueRefTest, givenUniquePtrWithCustomDeleterInstance_whenMovedToUniquePtr_thenHasSameDeleterInstance) {