add CMake Test

This commit is contained in:
scientiist
2023-04-25 12:21:21 -05:00
parent 7e6601fd7e
commit b1c28150c2
3 changed files with 47 additions and 0 deletions

View File

@@ -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;}

View File

@@ -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
View 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)