Skip to content

Commit

Permalink
iox-eclipse-iceoryx#1104 unique_ptr is no longer nullable - full inte…
Browse files Browse the repository at this point in the history
…gration into iceoryx_hoofs

Signed-off-by: Christian Eltzschig <[email protected]>
  • Loading branch information
elfenpiff committed Sep 27, 2022
1 parent f072b31 commit 0e88af0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion iceoryx_hoofs/source/posix_wrapper/access_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ AccessController::createACL(const int32_t numEntries) noexcept
cxx::Ensures(!aclFreeCall.has_error() && "Could not free ACL memory");
};

return cxx::success<smartAclPointer_t>(aclInitCall->value, freeACL);
return cxx::success<smartAclPointer_t>(*aclInitCall->value, freeACL);
}

bool AccessController::addUserPermission(const Permission permission, const PosixUser::userName_t& name) noexcept
Expand Down
22 changes: 22 additions & 0 deletions iceoryx_hoofs/test/moduletests/test_cxx_unique_ptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,28 @@ TEST_F(UniquePtrTest, SwapTwoValidUniquePtrsWithDifferentDeletersSucceeds)
EXPECT_TRUE(m_anotherDeleterCalled);
}

TEST_F(UniquePtrTest, SwapUniquePtrWithUniquePtrLeadsToCleanupOfBothInReverseOrder)
{
::testing::Test::RecordProperty("TEST_ID", "9017ba22-ff18-41d4-8590-ccb0d7729435");
{
auto sut = iox::cxx::unique_ptr<Position>(&object, deleter);
{
auto anotherSut = iox::cxx::unique_ptr<Position>(&anotherObject, anotherDeleter);

sut.swap(anotherSut);

// no deleter calls during swap
EXPECT_FALSE(m_deleterCalled);
EXPECT_EQ(anotherSut.get(), &object);
}
// anotherSUT is out of scope and calls its deleter, which has been swapped and is now 'deleter'
EXPECT_TRUE(m_deleterCalled);
EXPECT_FALSE(m_anotherDeleterCalled);
}
// SUT is out of scope and calling anotherDeleter
EXPECT_TRUE(m_anotherDeleterCalled);
}

TEST_F(UniquePtrTest, CompareAUniquePtrWithItselfIsTrue)
{
::testing::Test::RecordProperty("TEST_ID", "d12f8cf6-e37e-424a-9ed5-aea580b8bdc9");
Expand Down

0 comments on commit 0e88af0

Please sign in to comment.