diff --git a/unittest/vslib/Makefile.am b/unittest/vslib/Makefile.am index 390520cb831b..4da99c8dee66 100644 --- a/unittest/vslib/Makefile.am +++ b/unittest/vslib/Makefile.am @@ -10,7 +10,8 @@ tests_SOURCES = main.cpp \ TestCorePortIndexMap.cpp \ TestCorePortIndexMapContainer.cpp \ TestCorePortIndexMapFileParser.cpp \ - TestEventPayloadNetLinkMsg.cpp + TestEventPayloadNetLinkMsg.cpp \ + TestEventPayloadPacket.cpp tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) tests_LDADD = $(LDADD_GTEST) $(top_srcdir)/vslib/libSaiVS.a -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS) diff --git a/unittest/vslib/TestEventPayloadPacket.cpp b/unittest/vslib/TestEventPayloadPacket.cpp new file mode 100644 index 000000000000..079cdad22879 --- /dev/null +++ b/unittest/vslib/TestEventPayloadPacket.cpp @@ -0,0 +1,55 @@ +#include "EventPayloadPacket.h" + +#include + +#include + +using namespace saivs; + +TEST(EventPayloadPacket, ctr) +{ + uint8_t data[2] = { 1, 2 }; + + Buffer b(data, 2); + + EventPayloadPacket ep(0, 1, "foo", b); +} + +TEST(EventPayloadPacket, getPort) +{ + uint8_t data[2] = { 1, 2 }; + Buffer b(data, 2); + EventPayloadPacket ep(0, 1, "foo", b); + + EXPECT_EQ(ep.getPort(), 0); +} + +TEST(EventPayloadPacket, getIfIndex) +{ + uint8_t data[2] = { 1, 2 }; + Buffer b(data, 2); + EventPayloadPacket ep(0, 1, "foo", b); + + EXPECT_EQ(ep.getIfIndex(), 1); +} + +TEST(EventPayloadPacket, getIfName) +{ + uint8_t data[2] = { 1, 2 }; + Buffer b(data, 2); + EventPayloadPacket ep(0, 1, "foo", b); + + EXPECT_EQ(ep.getIfName(), "foo"); +} + +TEST(EventPayloadPacket, getBuffer) +{ + uint8_t data[2] = { 1, 2 }; + Buffer b(data, 2); + EventPayloadPacket ep(0, 1, "foo", b); + + auto&bb = ep.getBuffer(); + + EXPECT_EQ(bb.getData()[0], 1); + EXPECT_EQ(bb.getData()[1], 2); +}