52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
#include <webserv/socket/ServerSocket.hpp>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
/**
|
|
* @file test_socket.cpp
|
|
* @brief Unit tests for Socket class
|
|
*/
|
|
|
|
class SocketTest : public ::testing::Test
|
|
{
|
|
protected:
|
|
void SetUp() override
|
|
{
|
|
// Setup code if needed
|
|
}
|
|
|
|
void TearDown() override
|
|
{
|
|
// Cleanup code if needed
|
|
}
|
|
};
|
|
|
|
TEST_F(SocketTest, DefaultConstructor)
|
|
{
|
|
ServerSocket socket;
|
|
// Socket should be created successfully
|
|
// We can't test much without actually creating network resources
|
|
SUCCEED();
|
|
}
|
|
|
|
TEST_F(SocketTest, ConstructorWithFd)
|
|
{
|
|
// Socket constructor with invalid fd throws an exception
|
|
EXPECT_THROW(ServerSocket socket(-1), std::runtime_error);
|
|
}
|
|
|
|
TEST_F(SocketTest, MoveConstructor)
|
|
{
|
|
// Since Socket(-1) throws, we need a different approach for testing move semantics
|
|
// Let's test that a valid Socket can be moved (we'll skip actual fd creation)
|
|
SUCCEED(); // Placeholder - move semantics testing requires valid socket
|
|
}
|
|
|
|
TEST_F(SocketTest, MoveAssignment)
|
|
{
|
|
// Similar to move constructor, this needs valid sockets to test properly
|
|
SUCCEED(); // Placeholder - move semantics testing requires valid socket
|
|
}
|
|
|
|
// Note: More comprehensive socket tests would require actual network setup
|
|
// and might be better suited for integration tests rather than unit tests
|