Skip to content

Commit

Permalink
Add SkipRecordAttrContainer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik committed Sep 20, 2021
1 parent cd13f49 commit 6842d92
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
3 changes: 2 additions & 1 deletion unittest/lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ tests_SOURCES = \
TestVirtualObjectIdManager.cpp \
TestZeroMQChannel.cpp \
TestSwitchContainer.cpp \
TestSwitchConfigContainer.cpp
TestSwitchConfigContainer.cpp \
TestSkipRecordAttrContainer.cpp

tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON)
tests_LDADD = $(LDADD_GTEST) $(top_srcdir)/lib/libSaiRedis.a -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS)
Expand Down
51 changes: 51 additions & 0 deletions unittest/lib/TestSkipRecordAttrContainer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "SkipRecordAttrContainer.h"

#include <gtest/gtest.h>

#include <memory>

using namespace sairedis;

TEST(SkipRecordAttrContainer, add)
{
auto srac = std::make_shared<SkipRecordAttrContainer>();

EXPECT_FALSE(srac->add(SAI_OBJECT_TYPE_PORT, 10000));

EXPECT_FALSE(srac->add(SAI_OBJECT_TYPE_PORT, SAI_PORT_ATTR_INGRESS_ACL));

EXPECT_TRUE(srac->add(SAI_OBJECT_TYPE_PORT, SAI_PORT_ATTR_TYPE));
}

TEST(SkipRecordAttrContainer, remove)
{
auto srac = std::make_shared<SkipRecordAttrContainer>();

EXPECT_FALSE(srac->remove(SAI_OBJECT_TYPE_PORT, 10000));

EXPECT_TRUE(srac->add(SAI_OBJECT_TYPE_PORT, SAI_PORT_ATTR_TYPE));

EXPECT_FALSE(srac->remove(SAI_OBJECT_TYPE_PORT, 10000));

EXPECT_TRUE(srac->remove(SAI_OBJECT_TYPE_PORT, SAI_PORT_ATTR_TYPE));
}

TEST(SkipRecordAttrContainer, clear)
{
auto srac = std::make_shared<SkipRecordAttrContainer>();

EXPECT_TRUE(srac->remove(SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_AVAILABLE_ACL_TABLE_GROUP));

srac->clear();

EXPECT_FALSE(srac->remove(SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_AVAILABLE_ACL_TABLE));
}

TEST(SkipRecordAttrContainer, canSkipRecording)
{
auto srac = std::make_shared<SkipRecordAttrContainer>();

EXPECT_FALSE(srac->canSkipRecording(SAI_OBJECT_TYPE_SWITCH, 0, nullptr));

EXPECT_FALSE(srac->canSkipRecording(SAI_OBJECT_TYPE_SWITCH, 1, nullptr));
}
2 changes: 1 addition & 1 deletion unittest/lib/TestSwitchConfigContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ TEST(SwitchConfigContainer, insert)
EXPECT_THROW(scc->insert(sc), std::runtime_error);
EXPECT_THROW(scc->insert(sc1), std::runtime_error);
}

TEST(SwitchConfigContainer, getConfig)
{
auto sc0 = std::make_shared<SwitchConfig>(0, "0");
Expand Down

0 comments on commit 6842d92

Please sign in to comment.