Skip to content

Commit

Permalink
iox-eclipse-iceoryx#751 Add unnamed semaphore tests
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Eltzschig <me@elchris.org>
  • Loading branch information
elfenpiff committed May 23, 2022
1 parent 12a2afb commit 55b71ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ class UnnamedSemaphore final : public internal::SemaphoreInterface<UnnamedSemaph
UnnamedSemaphore& operator=(UnnamedSemaphore&&) noexcept = delete;
~UnnamedSemaphore() noexcept;

private:
friend class UnnamedSemaphoreBuilder;
friend class iox::cxx::optional<UnnamedSemaphore>;
friend class SemaphoreInterface<UnnamedSemaphore>;

private:
UnnamedSemaphore() noexcept = default;
iox_sem_t* getHandle() noexcept;

Expand Down
13 changes: 12 additions & 1 deletion iceoryx_hoofs/test/moduletests/test_posix_unnamed_semaphore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,19 @@ class UnnamedSemaphoreTest : public Test
optional<UnnamedSemaphore> sut;
};

TEST_F(UnnamedSemaphoreTest, asd)
TEST_F(UnnamedSemaphoreTest, DefaultInitialValueIsZero)
{
ASSERT_FALSE(UnnamedSemaphoreBuilder().create(sut).has_error());
EXPECT_THAT(0U, sut->getState().expect("Failed to access semaphore").value);
}

TEST_F(UnnamedSemaphoreTest, InitialValueIsSetOnCreation)
{
for (uint32_t initialValue = 313; initialValue < 10000; initialValue *= 3)
{
ASSERT_FALSE(UnnamedSemaphoreBuilder().initialValue(initialValue).create(sut).has_error());
EXPECT_THAT(initialValue, sut->getState().expect("Failed to access semaphore").value);
}
}
} // namespace

0 comments on commit 55b71ba

Please sign in to comment.