1 #include <gtest/gtest.h> 4 #include "utilities/dequeue_buffer.h" 9 EXPECT_NE(dut.
Head(),
nullptr);
10 EXPECT_EQ(dut.
Size(), 0);
12 size_t chars =
static_cast<size_t>(snprintf(dut.
Tail(), dut.
TailSpace(),
"hello "));
14 chars =
static_cast<size_t>(snprintf(dut.
Tail(), dut.
TailSpace(),
"world"));
16 EXPECT_EQ(dut.
Size(), strlen(
"hello world"));
18 EXPECT_EQ(std::string(dut.
Head(), dut.
Size()),
"hello world");
20 EXPECT_EQ(std::string(dut.
Head(), dut.
Size()),
"lo world");
24 int main(
int argc,
char **argv) {
25 ::testing::InitGoogleTest(&argc, argv);
26 return RUN_ALL_TESTS();
void HaveEnqueued(size_t bytes)
Call to indicate that bytes have been written in the range Tail() ...
char * Head()
A pointer to the first element that has not been Consumed().
size_t Size() const
The number of elements that are valid (have been written) after Head()
void Consume(size_t bytes)
Called after bytes have been read from Head().
size_t TailSpace()
The number of bytes beyond Tail() that are allocated and may be written to.
A dequeue based on a contiguous buffer in memory.
char * Tail()
A pointer to the next place to write data to.