Skip to content

Commit

Permalink
Add LaneMapFileParser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik committed Aug 23, 2021
1 parent 38a52ac commit b14b598
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion unittest/vslib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ tests_SOURCES = main.cpp \
TestFdbInfo.cpp \
TestSaiAttrWrap.cpp \
TestLaneMap.cpp \
TestLaneMapContainer.cpp
TestLaneMapContainer.cpp \
TestLaneMapFileParser.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
24 changes: 24 additions & 0 deletions unittest/vslib/TestLaneMapFileParser.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "LaneMapFileParser.h"

#include <gtest/gtest.h>

using namespace saivs;

TEST(LaneMapFileParser, isInterfaceNameValid)
{
EXPECT_FALSE(LaneMapFileParser::isInterfaceNameValid(""));
EXPECT_FALSE(LaneMapFileParser::isInterfaceNameValid("111111111111111111111111111111111111111"));
EXPECT_FALSE(LaneMapFileParser::isInterfaceNameValid("ab09AZ:"));
}


TEST(LaneMapFileParser, parseLaneMapFile)
{
EXPECT_NE(LaneMapFileParser::parseLaneMapFile(nullptr), nullptr);

EXPECT_NE(LaneMapFileParser::parseLaneMapFile("not_existing"), nullptr);

EXPECT_NE(LaneMapFileParser::parseLaneMapFile("files/lane_map_empty.txt"), nullptr);

EXPECT_NE(LaneMapFileParser::parseLaneMapFile("files/lane_nap_ok.txt"), nullptr);
}
8 changes: 8 additions & 0 deletions unittest/vslib/files/lane_map_empty.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
;
token
0:x_x:0
0:x_x:0,1,2
d:d
d:d:d
0:ed:0,1,2
1 change: 1 addition & 0 deletions unittest/vslib/files/lane_map_ok.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0:eth1:1,2,3,4

0 comments on commit b14b598

Please sign in to comment.