29 #include <gtest/gtest.h>
33 #define TEST_PORT_1 7893
34 #define TEST_PORT_2 7894
55 TEST(SocketTest, DefaultBehavior)
67 TEST(SocketTest, DisableAll)
76 TEST(SocketTest, ListenToPort)
80 EXPECT_NE(-1, listen_socket.
getfd());
85 TEST(SocketTest, ListenToPortReuseFalse)
93 EXPECT_NE(-1, listen_socket.
getfd());
98 TEST(SocketTest, RelistenWithSameInstanceSamePort)
106 testing::internal::CaptureStderr();
108 std::string
expected =
"panic: Socket already listening!\n";
109 std::string actual = testing::internal::GetCapturedStderr().substr();
119 actual = actual.substr(actual.find(
":", actual.find(
":") + 1) + 2);
123 TEST(SocketTest, RelistenWithSameInstanceDifferentPort)
131 testing::internal::CaptureStderr();
134 std::string
expected =
"panic: Socket already listening!\n";
135 std::string actual = testing::internal::GetCapturedStderr().substr();
136 actual = actual.substr(actual.find(
":", actual.find(
":") + 1) + 2);
140 TEST(SocketTest, RelistenWithDifferentInstanceOnDifferentPort)
152 TEST(SocketTest, RelistenWithDifferentInstanceOnSamePort)