Skip to content

Commit

Permalink
Add EventQueue tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik committed Aug 23, 2021
1 parent 752d424 commit 7ed640d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
3 changes: 2 additions & 1 deletion unittest/vslib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ tests_SOURCES = main.cpp \
TestCorePortIndexMapContainer.cpp \
TestCorePortIndexMapFileParser.cpp \
TestEventPayloadNetLinkMsg.cpp \
TestEventPayloadPacket.cpp
TestEventPayloadPacket.cpp \
TestEventQueue.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)
Expand Down
25 changes: 25 additions & 0 deletions unittest/vslib/TestEventQueue.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "EventQueue.h"

#include <linux/if.h>

#include <gtest/gtest.h>

using namespace saivs;

TEST(EventQueue, ctr)
{
EXPECT_THROW(std::make_shared<EventQueue>(nullptr), std::runtime_error);

auto s = std::make_shared<Signal>();

EventQueue eq(s);
}

TEST(EventQueue, size)
{
auto s = std::make_shared<Signal>();

EventQueue eq(s);

EXPECT_EQ(eq.size(), 0);
}
5 changes: 4 additions & 1 deletion vslib/EventQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ EventQueue::EventQueue(
{
SWSS_LOG_ENTER();

// empty
if (signal == nullptr)
{
SWSS_LOG_THROW("signal can't be nullptr");
}
}

void EventQueue::enqueue(
Expand Down

0 comments on commit 7ed640d

Please sign in to comment.