From 6fc213de020ff7761a82d879273b6d54d7046e4a Mon Sep 17 00:00:00 2001 From: kcudnik Date: Mon, 13 Sep 2021 10:25:14 +0200 Subject: [PATCH] Add SwitchConfigContainer tests --- unittest/lib/TestSwitchConfigContainer.cpp | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 unittest/lib/TestSwitchConfigContainer.cpp diff --git a/unittest/lib/TestSwitchConfigContainer.cpp b/unittest/lib/TestSwitchConfigContainer.cpp new file mode 100644 index 000000000..87e37a4b9 --- /dev/null +++ b/unittest/lib/TestSwitchConfigContainer.cpp @@ -0,0 +1,36 @@ +#include "SwitchConfigContainer.h" + +#include + +#include + +using namespace sairedis; + +TEST(SwitchConfigContainer, insert) +{ + auto sc = std::make_shared(0, ""); + auto sc1 = std::make_shared(1, ""); + + auto scc = std::make_shared(); + + 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(0, "0"); + auto sc1 = std::make_shared(1, "1"); + + auto scc = std::make_shared(); + + scc->insert(sc0); + scc->insert(sc1); + + EXPECT_EQ(scc->getConfig(7), nullptr); + + EXPECT_NE(scc->getConfig(1), nullptr); + EXPECT_NE(scc->getConfig(0), nullptr); +}