コード例 #1
0
ファイル: CircularBufferTest.cpp プロジェクト: RobinLiu/Test
TEST(CircularBuffer, PrintAfterOnePut)
{
    MockPrinter mock;

    buffer->Put(1);
    buffer->Print(&mock);
    CHECK_EQUAL("Circular buffer content:\n<1>\n",
                mock.getOutput());
}
コード例 #2
0
ファイル: CircularBufferTest.cpp プロジェクト: RobinLiu/Test
TEST(CircularBuffer, PrintEmpty)
{
    MockPrinter mock;
    Printer* p = &mock;

    buffer->Print(p);
    CHECK_EQUAL("Circular buffer content:\n<>\n",
                mock.getOutput());
}
コード例 #3
0
ファイル: CircularBufferTest.cpp プロジェクト: RobinLiu/Test
TEST(CircularBuffer, PrintNotYetWrappedOrFull)
{
    MockPrinter mock;

    buffer->Put(1);
    buffer->Put(2);
    buffer->Put(3);
    buffer->Print(&mock);
    CHECK_EQUAL("Circular buffer content:\n<1, 2, 3>\n",
                mock.getOutput());
}
コード例 #4
0
TEST(CircularBuffer, FillEmptyThenPrint)
{
	MockPrinter mock;

	fillTheQueue(200, buffer->Capacity());
	removeFromQueue(buffer->Capacity());
	buffer->Print(&mock);
	const char* expected = "Circular buffer content:\n"
		"<>\n";

	CHECK_EQUAL(expected, mock.getOutput());
}
コード例 #5
0
TEST(CircularBuffer, PrintNotYetWrappedAndIsFull)
{
	MockPrinter mock;

	fillTheQueue(200, buffer->Capacity());

	buffer->Print(&mock);
	const char* expected = "Circular buffer content:\n"
		"<200, 201, 202, 203, 204>\n";

	CHECK_EQUAL(expected, mock.getOutput());
}
コード例 #6
0
TEST(CircularBuffer, PrintWrappedAndFullOverwriteOldest)
{
	MockPrinter mock;

	fillTheQueue(200, buffer->Capacity());
	buffer->Put(9999);

	buffer->Print(&mock);
	const char* expected = "Circular buffer content:\n"
		"<201, 202, 203, 204, 9999>\n";

	CHECK_EQUAL(expected, mock.getOutput());
}
コード例 #7
0
TEST(CircularBuffer, PrintBoundary)
{
	MockPrinter mock;

	fillTheQueue(200, buffer->Capacity());
	removeFromQueue(buffer->Capacity() - 2);
	buffer->Put(888);
	fillTheQueue(300, buffer->Capacity() - 1);

	buffer->Print(&mock);
	const char* expected = "Circular buffer content:\n"
		"<888, 300, 301, 302, 303>\n";

	CHECK_EQUAL(expected, mock.getOutput());
}