Cy Schubert 2b15cb3d09 MFV ntp 4.2.8p1 (r258945, r275970, r276091, r276092, r276093, r278284)
Thanks to roberto for providing pointers to wedge this into HEAD.

Approved by:	roberto
2015-03-30 13:30:15 +00:00

39 lines
842 B
C++

#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());
}