Skip to content

Commit

Permalink
Add SelectableFd tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik committed Aug 23, 2021
1 parent 21e735d commit 7c016f0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
26 changes: 26 additions & 0 deletions unittest/vslib/TestSelectableFd.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "SelectableFd.h"

#include <gtest/gtest.h>

using namespace saivs;

TEST(SelectableFd, ctr)
{
EXPECT_THROW(std::make_shared<SelectableFd>(-1), std::runtime_error);

SelectableFd fd(0);
}

TEST(SelectableFd, getFd)
{
SelectableFd fd(7);

EXPECT_EQ(fd.getFd(), 7);
}

TEST(SelectableFd, readData)
{
SelectableFd fd(7);

EXPECT_EQ(fd.readData(), 0);
}
5 changes: 5 additions & 0 deletions vslib/SelectableFd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ SelectableFd::SelectableFd(
{
SWSS_LOG_ENTER();

if (fd < 0)
{
SWSS_LOG_THROW("invalid file descriptor: %d", fd);
}

m_fd = fd;
}

Expand Down

0 comments on commit 7c016f0

Please sign in to comment.