add CMake Test
This commit is contained in:
@@ -23,12 +23,24 @@ namespace Socket
|
||||
void Open();
|
||||
int Close();
|
||||
bool IsClosed() const { return sock < 0;}
|
||||
<<<<<<< Updated upstream
|
||||
void Bind(const IPAddress& ipAddress);
|
||||
void Bind(uint16_t portno);
|
||||
void BindAny();
|
||||
void BindAny(uint16_t& portno);
|
||||
void Connect(const IPAddress& ipaddr);
|
||||
void Connect(uint16_t portno);
|
||||
=======
|
||||
void Bind(const IPAddress& ipaddr);
|
||||
void Bind(uint16_t portno);
|
||||
void BindAny();
|
||||
void BindAny(uint16_t& portno);
|
||||
void Connect(const IPAddress& ipaddr);
|
||||
void Connect(uint16_t portno);
|
||||
<<<<<<< Updated upstream
|
||||
>>>>>>> Stashed changes
|
||||
=======
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
[[nodiscard]] IPAddress GetSelfIP() const {return self_addr;}
|
||||
[[nodiscard]] IPAddress GetPeerIP() const {return peer_addr;}
|
||||
|
@@ -36,7 +36,15 @@ namespace Socket
|
||||
return 0;
|
||||
}
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
<<<<<<< Updated upstream
|
||||
void UdpSocket::Bind(const IPAddress& ipAddress)
|
||||
=======
|
||||
void UdpSocket::Bind(IPAddress& ipaddr)
|
||||
>>>>>>> Stashed changes
|
||||
=======
|
||||
void UdpSocket::Bind(IPAddress& ipaddr)
|
||||
>>>>>>> Stashed changes
|
||||
{
|
||||
self_addr = ipAddress;
|
||||
self_addr_len = sizeof(self_addr);
|
||||
@@ -66,8 +74,20 @@ namespace Socket
|
||||
}
|
||||
void UdpSocket::BindAny(uint16_t& portno)
|
||||
{
|
||||
<<<<<<< Updated upstream
|
||||
<<<<<<< Updated upstream
|
||||
this->Bind(INPORT_ANY);
|
||||
portno = IPAddress{self_addr}.port;
|
||||
=======
|
||||
this->Bind(INPORT_ANY);
|
||||
portno = IPAddress{self_addr}.port;
|
||||
//return 0;
|
||||
>>>>>>> Stashed changes
|
||||
=======
|
||||
this->Bind(INPORT_ANY);
|
||||
portno = IPAddress{self_addr}.port;
|
||||
//return 0;
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
void UdpSocket::Connect(const IPAddress& ipaddr)
|
||||
{
|
||||
@@ -81,7 +101,15 @@ namespace Socket
|
||||
void UdpSocket::Connect(uint16_t portno)
|
||||
{
|
||||
auto ipaddr = IPAddress::Loopback(portno);
|
||||
<<<<<<< Updated upstream
|
||||
<<<<<<< Updated upstream
|
||||
this->Connect(ipaddr);
|
||||
=======
|
||||
this->Connect(ipaddr);
|
||||
>>>>>>> Stashed changes
|
||||
=======
|
||||
this->Connect(ipaddr);
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
7
tests/CMakeLists.txt
Normal file
7
tests/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
file(GLOB_RECURSE TEST_SRCS "*.cpp")
|
||||
add_executable(Test ${TEST_SRCS})
|
||||
target_link_libraries(Test PUBLIC Sockets)
|
||||
find_package(GTest REQUIRED)
|
||||
target_link_libraries(Test PRIVATE GTest::gtest)
|
||||
include_directories("include")
|
||||
add_test(NAME "Test" COMMAND Test)
|
Reference in New Issue
Block a user