Skip to content

Commit

Permalink
-fixed gcc warnings
Browse files Browse the repository at this point in the history
-dropped dependency on installed googletest for unit tests and started fetching it
-updated the version to 1.3.1;
  • Loading branch information
kamchatka-volcano committed Aug 26, 2022
1 parent c925024 commit 66a81e0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 15 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.18)

project(fcgi_responder VERSION 1.3.0 DESCRIPTION "FastCGI protocol responder role implementation library")
project(fcgi_responder VERSION 1.3.1 DESCRIPTION "FastCGI protocol responder role implementation library")

if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(FCGI_RESPONDER_SUBPROJECT OFF)
Expand Down Expand Up @@ -60,7 +60,6 @@ target_include_directories(

option(ENABLE_TESTS "Enable tests" OFF)
if (ENABLE_TESTS AND NOT FCGI_RESPONDER_SUBPROJECT)
enable_testing()
add_subdirectory(tests)
endif()

Expand Down
22 changes: 15 additions & 7 deletions src/requesterimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,24 @@
#include "record.h"
#include "streammaker.h"
#include <cstdint>
#include <exception>

namespace fcgi{

namespace {
std::set<uint16_t> generateRequestIds(int maxRequestsNumber)
{
auto result = std::set<uint16_t>{};
for (auto i = 1; i <= maxRequestsNumber; ++i)
result.insert(static_cast<uint16_t>(i));
return result;
}
std::set<uint16_t> generateRequestIds(int maxRequestsNumber)
{
auto result = std::set<uint16_t>{};
for (auto i = 1; i <= maxRequestsNumber; ++i)
result.insert(static_cast<uint16_t>(i));
return result;
}

[[noreturn]]
inline void ensureNotReachable() noexcept
{
std::terminate();
}
}

RequesterImpl::RequesterImpl(
Expand Down Expand Up @@ -63,6 +70,7 @@ int RequesterImpl::availableRequestsNumber() const
case ConnectionState::Connected:
return static_cast<int>(requestIdPool_.size());
}
ensureNotReachable();
}

void RequesterImpl::initConnection(
Expand Down
16 changes: 10 additions & 6 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
cmake_minimum_required(VERSION 3.18)
project(test_fcgi)

find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})
enable_testing()
include(external/googletest)

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

set(SRC
test_record_serialization.cpp
test_request.cpp
test_utils.cpp
test_record_serialization.cpp
test_request.cpp
test_utils.cpp
test_responder.cpp
test_requester.cpp)

Expand All @@ -20,4 +21,7 @@ set_target_properties(test_fcgi PROPERTIES CXX_EXTENSIONS OFF)
add_test(NAME test_fcgi COMMAND test_fcgi)
target_include_directories(test_fcgi PRIVATE ../include/fcgi_responder)
target_include_directories(test_fcgi PRIVATE ../src)
target_link_libraries(test_fcgi PRIVATE ${GTEST_BOTH_LIBRARIES} gmock Threads::Threads fcgi_responder::fcgi_responder)
target_link_libraries(test_fcgi PRIVATE GTest::gtest_main GTest::gmock_main Threads::Threads fcgi_responder::fcgi_responder)

include(GoogleTest)
gtest_discover_tests(test_fcgi)
14 changes: 14 additions & 0 deletions tests/external/googletest
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
include(FetchContent)
Set(FETCHCONTENT_QUIET FALSE)
if (NOT google_FOUND)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.0
GIT_SHALLOW ON
GIT_PROGRESS TRUE
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
endif()

0 comments on commit 66a81e0

Please sign in to comment.