Kata Step Six
Upon examining our last test, I can see that it just tests that we can retrieve an item, not that we actually removed the item from the queue.
Let’s change our test to prove that we can get two items in a row. That should do it.
BoundedQueueTest.cpp
TEST_F(BoundedQueueTest, FirstInFirstOut) {
q.enqueue(1);
q.enqueue(2);
ASSERT_EQ(1, q.dequeue());
ASSERT_EQ(2, q.dequeue());
}Ah, now the test fails. Now that we have a red bar, we can fix our implementation of dequeue().
Give it a try yourself, or read on:
Ah, this should work:
BoundedQueue.h
const T& dequeue() {
const T& item = q.front();
q.pop();
return item;
}Green bar again! It feels good.
Go on to BoundedQueueKataStepSeven.... or go back
