TEST(CircularBuffer, PrintAfterOnePut) { MockPrinter mock; buffer->Put(1); buffer->Print(&mock); CHECK_EQUAL("Circular buffer content:\n<1>\n", mock.getOutput()); }
TEST(CircularBuffer, PrintEmpty) { MockPrinter mock; Printer* p = &mock; buffer->Print(p); CHECK_EQUAL("Circular buffer content:\n<>\n", mock.getOutput()); }
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()); }
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()); }
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()); }
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()); }
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()); }