Skip to content

Commit

Permalink
Add SwitchConfigContainer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik committed Sep 20, 2021
1 parent ee24c0e commit 6fc213d
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions unittest/lib/TestSwitchConfigContainer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "SwitchConfigContainer.h"

#include <gtest/gtest.h>

#include <memory>

using namespace sairedis;

TEST(SwitchConfigContainer, insert)
{
auto sc = std::make_shared<SwitchConfig>(0, "");
auto sc1 = std::make_shared<SwitchConfig>(1, "");

auto scc = std::make_shared<SwitchConfigContainer>();

scc->insert(sc);

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");
auto sc1 = std::make_shared<SwitchConfig>(1, "1");

auto scc = std::make_shared<SwitchConfigContainer>();

scc->insert(sc0);
scc->insert(sc1);

EXPECT_EQ(scc->getConfig(7), nullptr);

EXPECT_NE(scc->getConfig(1), nullptr);
EXPECT_NE(scc->getConfig(0), nullptr);
}

0 comments on commit 6fc213d

Please sign in to comment.