Skip to content

Commit

Permalink
Update unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik committed Aug 23, 2021
1 parent 2418585 commit 466a589
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 11 deletions.
8 changes: 3 additions & 5 deletions unittest/lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ bin_PROGRAMS = tests
LDADD_GTEST = -L/usr/src/gtest -lgtest -lgtest_main

tests_SOURCES = \
main.cpp
main.cpp \
TestSwitch.cpp

#tests_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS)
#tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) $(CODE_COVERAGE_CXXFLAGS)
tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON)
tests_LDADD = $(LDADD_GTEST) -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS)
tests_LDADD = $(LDADD_GTEST) $(top_srcdir)/lib/libSaiRedis.a -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS)

TESTS = tests

10 changes: 10 additions & 0 deletions unittest/lib/TestSwitch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "Switch.h"

#include <gtest/gtest.h>

using namespace sairedis;

TEST(Switch, ctr)
{
EXPECT_THROW(new Switch(SAI_NULL_OBJECT_ID), std::runtime_error);
}
10 changes: 4 additions & 6 deletions unittest/vslib/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
AM_CXXFLAGS = $(SAIINC) -I$(top_srcdir)/meta -I$(top_srcdir)/lib
AM_CXXFLAGS = $(SAIINC) -I$(top_srcdir)/meta -I$(top_srcdir)/vslib

bin_PROGRAMS = tests

LDADD_GTEST = -L/usr/src/gtest -lgtest -lgtest_main

tests_SOURCES = \
main.cpp
main.cpp \
TestBuffer.cpp

#tests_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS)
#tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) $(CODE_COVERAGE_CXXFLAGS)
tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON)
tests_LDADD = $(LDADD_GTEST) -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS)
tests_LDADD = $(LDADD_GTEST) $(top_srcdir)/vslib/libSaiVS.a -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS)

TESTS = tests

48 changes: 48 additions & 0 deletions unittest/vslib/TestBuffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "Buffer.h"

#include <gtest/gtest.h>

using namespace saivs;

TEST(Buffer, ctr)
{
EXPECT_THROW(new Buffer(0,0), std::runtime_error);

Buffer b((const uint8_t*)"foo", 3);
}

TEST(Buffer, dtr)
{
auto b = std::make_shared<Buffer>((const uint8_t*)"foo", 3);

b = nullptr;
}

TEST(Buffer, getData)
{
EXPECT_THROW(new Buffer(0,0), std::runtime_error);

Buffer b((const uint8_t*)"foo", 3);

EXPECT_NE(b.getData(), nullptr);
}

TEST(Buffer, getSize)
{
EXPECT_THROW(new Buffer(0,0), std::runtime_error);

Buffer b((const uint8_t*)"foo", 3);

EXPECT_EQ(b.getSize(), 3);
}

TEST(Buffer, flow)
{
EXPECT_THROW(new Buffer(0,0), std::runtime_error);

Buffer b((const uint8_t*)"foo", 3);

EXPECT_NE(b.getData(), nullptr);

EXPECT_EQ(b.getSize(), 3);
}

0 comments on commit 466a589

Please sign in to comment.