feat: add missing unordered_map include for improved functionality
This commit is contained in:
parent
d360728b18
commit
610cc69fc1
@ -68,6 +68,9 @@ add_executable(webserv ${SOURCES} "${PROJECT_SOURCE_DIR}/webserv/main.cpp")
|
||||
add_library(webserv_lib ${SOURCES})
|
||||
|
||||
# Google Test integration
|
||||
option(BUILD_TESTS "Build tests" ON)
|
||||
|
||||
if(BUILD_TESTS)
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PkgConfig_FOUND)
|
||||
pkg_check_modules(GTEST gtest)
|
||||
@ -83,13 +86,72 @@ else()
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
|
||||
)
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
|
||||
# Make sure gtest targets are available
|
||||
if(TARGET gtest_main)
|
||||
message(STATUS "Google Test targets available")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Add test directory
|
||||
# Add test directory if it exists
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/tests")
|
||||
add_subdirectory(tests)
|
||||
else()
|
||||
message(STATUS "Tests directory not found, creating basic test structure")
|
||||
file(MAKE_DIRECTORY "${CMAKE_SOURCE_DIR}/tests")
|
||||
|
||||
# Create a basic test file
|
||||
file(WRITE "${CMAKE_SOURCE_DIR}/tests/test_main.cpp"
|
||||
"#include <gtest/gtest.h>
|
||||
|
||||
// Basic test to verify Google Test is working
|
||||
TEST(BasicTest, TruthTest) {
|
||||
EXPECT_TRUE(true);
|
||||
EXPECT_FALSE(false);
|
||||
EXPECT_EQ(1 + 1, 2);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
")
|
||||
|
||||
# Create CMakeLists.txt for tests
|
||||
file(WRITE "${CMAKE_SOURCE_DIR}/tests/CMakeLists.txt"
|
||||
"# Test executable
|
||||
add_executable(webserv_tests
|
||||
test_main.cpp
|
||||
)
|
||||
|
||||
# Link with Google Test
|
||||
if(TARGET gtest_main)
|
||||
target_link_libraries(webserv_tests
|
||||
gtest_main
|
||||
webserv_lib
|
||||
)
|
||||
else()
|
||||
target_link_libraries(webserv_tests
|
||||
\${GTEST_LIBRARIES}
|
||||
\${GTEST_MAIN_LIBRARIES}
|
||||
webserv_lib
|
||||
)
|
||||
target_include_directories(webserv_tests PRIVATE \${GTEST_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
target_include_directories(webserv_tests PRIVATE
|
||||
\${CMAKE_SOURCE_DIR}
|
||||
\${CMAKE_SOURCE_DIR}/webserv
|
||||
)
|
||||
|
||||
# Discover tests
|
||||
include(GoogleTest)
|
||||
gtest_discover_tests(webserv_tests)
|
||||
")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <string> // for basic_string, operator+, to_string, char_traits, string
|
||||
#include <utility> // for move, pair
|
||||
#include <vector> // for vector
|
||||
#include <unordered_map> // for unordered_map, unordered_map<>::container_type
|
||||
|
||||
#include <sys/epoll.h> // for epoll_event, epoll_ctl, EPOLLIN, EPOLLOUT, epoll_create1, epoll_wait, EPOLLERR, EPOLLHUP, EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD
|
||||
#include <sys/socket.h> // for send, SOMAXCONN
|
||||
|
||||
Loading…
Reference in New Issue
Block a user