2014-03-09 13:27:04 +00:00
|
|
|
// Copyright 2014 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2014-03-09 13:27:04 +00:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include "Common/FixedSizeQueue.h"
|
|
|
|
|
|
|
|
TEST(FixedSizeQueue, Simple)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
FixedSizeQueue<int, 5> q;
|
2014-03-09 13:27:04 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
EXPECT_EQ(0u, q.size());
|
2014-03-09 13:27:04 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
q.push(0);
|
|
|
|
q.push(1);
|
|
|
|
q.push(2);
|
|
|
|
q.push(3);
|
|
|
|
q.push(4);
|
|
|
|
for (int i = 0; i < 1000; ++i)
|
|
|
|
{
|
|
|
|
EXPECT_EQ(i, q.front());
|
|
|
|
EXPECT_EQ(i, q.pop_front());
|
|
|
|
q.push(i + 5);
|
|
|
|
}
|
|
|
|
EXPECT_EQ(1000, q.pop_front());
|
|
|
|
EXPECT_EQ(1001, q.pop_front());
|
|
|
|
EXPECT_EQ(1002, q.pop_front());
|
|
|
|
EXPECT_EQ(1003, q.pop_front());
|
|
|
|
EXPECT_EQ(1004, q.pop_front());
|
2014-03-09 13:27:04 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
EXPECT_EQ(0u, q.size());
|
2014-03-09 13:27:04 +00:00
|
|
|
}
|