diff options
Diffstat (limited to 'tests/libntp/recvbuff.cpp')
-rw-r--r-- | tests/libntp/recvbuff.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/libntp/recvbuff.cpp b/tests/libntp/recvbuff.cpp new file mode 100644 index 0000000..e9505bd --- /dev/null +++ b/tests/libntp/recvbuff.cpp @@ -0,0 +1,38 @@ +#include "libntptest.h" + +extern "C" { +#include "recvbuff.h" +}; + +class recvbuffTest : public libntptest { +protected: + virtual void SetUp() { + init_recvbuff(RECV_INIT); + } +}; + +TEST_F(recvbuffTest, Initialization) { + EXPECT_EQ(RECV_INIT, free_recvbuffs()); + EXPECT_EQ(0, full_recvbuffs()); + EXPECT_FALSE(has_full_recv_buffer()); + EXPECT_TRUE(get_full_recv_buffer() == NULL); +} + +TEST_F(recvbuffTest, GetAndFree) { + int initial = free_recvbuffs(); + recvbuf_t* buf = get_free_recv_buffer(); + + EXPECT_EQ(initial-1, free_recvbuffs()); + freerecvbuf(buf); + EXPECT_EQ(initial, free_recvbuffs()); +} + +TEST_F(recvbuffTest, GetAndFill) { + int initial = free_recvbuffs(); + recvbuf_t* buf = get_free_recv_buffer(); + + add_full_recv_buffer(buf); + EXPECT_EQ(1, full_recvbuffs()); + EXPECT_TRUE(has_full_recv_buffer()); + EXPECT_EQ(buf, get_full_recv_buffer()); +} |