tests/comms: Add some tests for SockAddrInet/Unix

This commit is contained in:
Peter Keresztes Schmidt 2021-04-09 19:53:31 +02:00
parent 5aa508bc74
commit 45986c8ee2
1 changed files with 32 additions and 0 deletions

View File

@ -91,3 +91,35 @@ TEST_CASE("ZM::Pipe read/write") {
REQUIRE(pipe.read(rcv.data(), rcv.size()) == -1);
}
}
TEST_CASE("ZM::SockAddrInet") {
ZM::SockAddrInet addr;
REQUIRE(addr.getAddrSize() == sizeof(sockaddr_in));
SECTION("resolve") {
addr.resolve(80, "");
REQUIRE(addr.getDomain() == AF_INET);
SECTION("newSockAddr from resolved addr") {
ZM::SockAddr *addr2 = ZM::SockAddr::newSockAddr(&addr);
REQUIRE(addr2->getDomain() == AF_INET);
REQUIRE(addr2->getAddrSize() == sizeof(sockaddr_in));
}
}
}
TEST_CASE("ZM::SockAddrUnix") {
ZM::SockAddrUnix addr;
REQUIRE(addr.getAddrSize() == sizeof(sockaddr_un));
SECTION("resovle") {
addr.resolve("/", "");
REQUIRE(addr.getDomain() == AF_UNIX);
SECTION("newSockAddr from resolved addr") {
ZM::SockAddr *addr2 = ZM::SockAddr::newSockAddr(&addr);
REQUIRE(addr2->getDomain() == AF_UNIX);
REQUIRE(addr2->getAddrSize() == sizeof(sockaddr_un));
}
}
}