Skip to content

Commit

Permalink
iox-eclipse-iceoryx#80 fixed index queue test
Browse files Browse the repository at this point in the history
Signed-off-by: Killat Matthias (CC-AD/ESW1) <matthias.killat2@de.bosch.com>
  • Loading branch information
Killat Matthias (CC-AD/ESW1) committed Jun 9, 2020
1 parent 3f3b288 commit de963d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class IndexQueue
/// @return the underlying value
ValueType release()
{
auto value = std::move(m_value.value());
ValueType value = std::move(m_value.value());
m_value.reset();
return value;
}
Expand Down
19 changes: 16 additions & 3 deletions iceoryx_utils/test/moduletests/test_index_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,27 @@ TYPED_TEST(IndexQueueTest, queueIsEmptyWhenPopFails)

TYPED_TEST(IndexQueueTest, pushAndPopSingleElement)
{
using index_t = typename TestFixture::index_t;
auto& q = this->queue;
auto index = this->fullQueue.pop();

// we need to store a raw index to compare it,
// but we cannot copy nor move it since we want to push it back
// which invalidates the index
// but we can copy the raw index
// (but not create a index to return to the queue from it again)
index_t rawIndex = index;

EXPECT_TRUE(index.isValid());

q.push(index);

EXPECT_FALSE(index.isValid());

auto popped = q.pop();

EXPECT_TRUE(popped.isValid());
EXPECT_EQ(popped, index);
ASSERT_TRUE(popped.isValid());
EXPECT_EQ(popped, rawIndex);
}

TYPED_TEST(IndexQueueTest, poppedElementsAreInFifoOrder)
Expand Down Expand Up @@ -213,4 +226,4 @@ TYPED_TEST(IndexQueueTest, popIfFullReturnsNothingWhenQueueIsNotFull)
EXPECT_FALSE(q.popIfFull().isValid());
}

}
} // namespace

0 comments on commit de963d1

Please sign in to comment.