TEST(CircularBuffer, OverlapPushBackFull)
{
    CircularBuffer<int, 5> cb;

    cb.pushBack(0);
    cb.pushBack(1);
    cb.pushBack(2);

    ASSERT_FALSE(cb.empty());
    ASSERT_EQ(cb.size(), 3);

    ASSERT_EQ(cb.popFront(), 0);
    ASSERT_EQ(cb.popFront(), 1);
    ASSERT_EQ(cb.popFront(), 2);

    cb.pushBack(0);
    cb.pushBack(1);
    cb.pushBack(2);
    cb.pushBack(3);
    cb.pushBack(4);

    ASSERT_FALSE(cb.empty());
    ASSERT_EQ(cb.size(), 5);

    ASSERT_EQ(cb.popFront(), 0);
    ASSERT_EQ(cb.popFront(), 1);
    ASSERT_EQ(cb.popFront(), 2);
    ASSERT_EQ(cb.popFront(), 3);
    ASSERT_EQ(cb.popFront(), 4);

    ASSERT_TRUE(cb.empty());
    ASSERT_EQ(cb.size(), 0);
}
TEST(CircularBuffer, EraseOverflow)
{
    CircularBuffer<int, 5> cb;

    cb.pushBack(9);
    cb.pushBack(9);
    cb.pushBack(9);

    cb.popFront();
    cb.popFront();
    cb.popFront();

    cb.pushBack(0);
    cb.pushBack(1);
    cb.pushBack(2);
    cb.pushBack(3);

    auto it(cb.begin());

    ++it;

    cb.erase(it);
    cb.erase(it);

    std::vector<int> values({ 0, 3 });

    ASSERT_TRUE(std::equal(cb.begin(), cb.end(),
                           values.begin()));
}
TEST(CircularBuffer, SimplePushBackPop)
{
    CircularBuffer<int, 5> cb;

    cb.pushBack(123);
    
    ASSERT_FALSE(cb.empty());
    ASSERT_EQ(cb.size(), 1);
    ASSERT_EQ(cb.popFront(), 123);
    ASSERT_TRUE(cb.empty());
    ASSERT_EQ(cb.size(), 0);    
}
TEST(CircularBuffer, SimplePushFrontFull)
{
    CircularBuffer<int, 5> cb;

    cb.pushFront(0);
    cb.pushFront(1);
    cb.pushFront(2);
    cb.pushFront(3);
    cb.pushFront(4);

    ASSERT_FALSE(cb.empty());
    ASSERT_EQ(cb.size(), 5);

    ASSERT_EQ(cb.popFront(), 4);
    ASSERT_EQ(cb.popFront(), 3);
    ASSERT_EQ(cb.popFront(), 2);
    ASSERT_EQ(cb.popFront(), 1);
    ASSERT_EQ(cb.popFront(), 0);

    ASSERT_TRUE(cb.empty());
    ASSERT_EQ(cb.size(), 0);
}
TEST(CircularBuffer, OverlapPushFrontPop)
{
    CircularBuffer<int, 5> cb;

    cb.pushFront(0);
    cb.pushFront(1);
    cb.pushFront(2);
    cb.pushFront(3);

    ASSERT_FALSE(cb.empty());
    ASSERT_EQ(cb.size(), 4);

    ASSERT_EQ(cb.popFront(), 3);
    ASSERT_EQ(cb.popFront(), 2);
    ASSERT_EQ(cb.popFront(), 1);
    ASSERT_EQ(cb.popFront(), 0);

    ASSERT_TRUE(cb.empty());
    ASSERT_EQ(cb.size(), 0);

    cb.pushFront(0);
    cb.pushFront(1);
    cb.pushFront(2);
    cb.pushFront(3);

    ASSERT_FALSE(cb.empty());
    ASSERT_EQ(cb.size(), 4);

    ASSERT_EQ(cb.popFront(), 3);
    ASSERT_EQ(cb.popFront(), 2);
    ASSERT_EQ(cb.popFront(), 1);
    ASSERT_EQ(cb.popFront(), 0);

    ASSERT_TRUE(cb.empty());
    ASSERT_EQ(cb.size(), 0);
}