build(deps): update catch2 from 1.10.0 to v3.3.2 (#400)
* build(deps): update catch2 from 1.10.0 to v3.3.2 * Use new catch version * Fix test * Remove catch submodule
This commit is contained in:
parent
9066882fa1
commit
9d55f6e10e
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -7,6 +7,3 @@
|
||||
[submodule "lib/asio"]
|
||||
path = lib/asio
|
||||
url = https://github.com/chriskohlhoff/asio.git
|
||||
[submodule "lib/catch"]
|
||||
path = lib/catch
|
||||
url = https://github.com/philsquared/Catch.git
|
||||
|
||||
@ -8,10 +8,6 @@ option(BUILD_SHARED_LIBS "Build the shared library" OFF)
|
||||
option(BUILD_UNIT_TESTS "Builds unit tests target" OFF)
|
||||
option(USE_SUBMODULES "Use source in local submodules instead of system libraries" ON)
|
||||
|
||||
set(MAJOR 1)
|
||||
set(MINOR 6)
|
||||
set(PATCH 0)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(DEFAULT_BUILD_TYPE "Release")
|
||||
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
|
||||
@ -21,13 +17,16 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src ALL_SRC)
|
||||
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src/internal ALL_SRC)
|
||||
|
||||
file(GLOB ALL_HEADERS ${CMAKE_CURRENT_LIST_DIR}/src/*.h)
|
||||
# Only do these if this is the main project, and not if it is included through add_subdirectory
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||
# Testing only available if this is the main app
|
||||
# Note this needs to be done in the main CMakeLists
|
||||
# since it calls enable_testing, which must be in the
|
||||
# main CMakeLists.
|
||||
include(CTest)
|
||||
endif()
|
||||
|
||||
add_definitions(
|
||||
|
||||
# These will force ASIO to compile without Boost
|
||||
-DBOOST_DATE_TIME_NO_LIB
|
||||
-DBOOST_REGEX_NO_LIB
|
||||
@ -40,6 +39,12 @@ add_definitions(
|
||||
-D_WEBSOCKETPP_CPP11_CHRONO_
|
||||
)
|
||||
|
||||
set(ALL_SRC
|
||||
"src/sio_client.cpp"
|
||||
"src/sio_socket.cpp"
|
||||
"src/internal/sio_client_impl.cpp"
|
||||
"src/internal/sio_packet.cpp"
|
||||
)
|
||||
add_library(sioclient ${ALL_SRC})
|
||||
|
||||
if(USE_SUBMODULES)
|
||||
@ -55,25 +60,22 @@ else()
|
||||
target_link_libraries(sioclient PRIVATE websocketpp::websocketpp asio asio::asio rapidjson)
|
||||
endif()
|
||||
|
||||
target_include_directories(sioclient PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
target_include_directories(sioclient
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
PRIVATE
|
||||
${MODULE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
if(CMAKE_VERSION VERSION_GREATER "3.1")
|
||||
set_property(TARGET sioclient PROPERTY CXX_STANDARD 11)
|
||||
set_property(TARGET sioclient PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||
else()
|
||||
set_property(TARGET sioclient APPEND_STRING PROPERTY COMPILE_FLAGS "-std=c++11")
|
||||
endif()
|
||||
set_property(TARGET sioclient PROPERTY CXX_STANDARD 11)
|
||||
set_property(TARGET sioclient PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set_target_properties(sioclient
|
||||
PROPERTIES
|
||||
SOVERSION ${MAJOR}
|
||||
VERSION ${MAJOR}.${MINOR}.${PATCH}
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
VERSION ${PROJECT_VERSION}
|
||||
)
|
||||
endif()
|
||||
|
||||
@ -84,7 +86,7 @@ find_package(OpenSSL)
|
||||
if(OPENSSL_FOUND)
|
||||
add_library(sioclient_tls ${ALL_SRC})
|
||||
target_include_directories(sioclient_tls PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
PRIVATE
|
||||
${MODULE_INCLUDE_DIRS}
|
||||
@ -104,8 +106,8 @@ if(OPENSSL_FOUND)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set_target_properties(sioclient_tls
|
||||
PROPERTIES
|
||||
SOVERSION ${MAJOR}
|
||||
VERSION ${MAJOR}.${MINOR}.${PATCH}
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
VERSION ${PROJECT_VERSION}
|
||||
)
|
||||
endif()
|
||||
|
||||
@ -116,6 +118,7 @@ export(PACKAGE sioclient)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
file(GLOB ALL_HEADERS ${CMAKE_CURRENT_LIST_DIR}/src/*.h)
|
||||
install(FILES ${ALL_HEADERS}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
@ -163,8 +166,6 @@ install(
|
||||
${ConfigPackageLocation}
|
||||
)
|
||||
|
||||
if(BUILD_UNIT_TESTS)
|
||||
message(STATUS "Building with unit test support.")
|
||||
enable_testing()
|
||||
if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) OR BUILD_UNIT_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
@ -1 +0,0 @@
|
||||
Subproject commit 9c07718b5f779bc1405f98ca6b5b693026f6eac7
|
||||
@ -1,9 +1,14 @@
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
Catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||
GIT_TAG v3.3.2
|
||||
)
|
||||
FetchContent_MakeAvailable(Catch2)
|
||||
|
||||
add_executable(sio_test sio_test.cpp)
|
||||
set_property(TARGET sio_test PROPERTY CXX_STANDARD 11)
|
||||
set_property(TARGET sio_test PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||
target_link_libraries(sio_test sioclient)
|
||||
target_include_directories(sio_test PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../lib/catch/include"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../src"
|
||||
)
|
||||
target_link_libraries(sio_test PRIVATE Catch2::Catch2WithMain sioclient)
|
||||
add_test(sioclient_test sio_test)
|
||||
|
||||
@ -10,8 +10,7 @@
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
|
||||
#include "catch.hpp"
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include "json.hpp" //nlohmann::json cannot build in MSVC
|
||||
@ -55,7 +54,7 @@ TEST_CASE( "test_packet_accept_1" )
|
||||
p.accept(payload,buffers);
|
||||
CHECK(buffers.size() == 0);
|
||||
CHECK(payload == "40/nsp");
|
||||
INFO("outputing payload:" << payload)
|
||||
INFO("outputing payload:" << payload);
|
||||
}
|
||||
|
||||
TEST_CASE( "test_packet_accept_2" )
|
||||
@ -66,7 +65,7 @@ TEST_CASE( "test_packet_accept_2" )
|
||||
p.accept(payload,buffers);
|
||||
CHECK(buffers.size() == 0);
|
||||
CHECK(payload == "2");
|
||||
INFO("outputing payload:" << payload)
|
||||
INFO("outputing payload:" << payload);
|
||||
}
|
||||
|
||||
TEST_CASE( "test_packet_accept_3" )
|
||||
@ -81,7 +80,7 @@ TEST_CASE( "test_packet_accept_3" )
|
||||
CHECK(p.get_type() == packet::type_ack);
|
||||
CHECK(buffers.size() == 0);
|
||||
CHECK(payload == "43/nsp,1001[\"event\",\"text\"]");
|
||||
INFO("outputing payload:" << payload)
|
||||
INFO("outputing payload:" << payload);
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
@ -106,26 +105,26 @@ TEST_CASE( "test_packet_accept_4" )
|
||||
REQUIRE(json_start!=std::string::npos);
|
||||
std::string header = payload.substr(0,json_start);
|
||||
CHECK(header=="452-/nsp,1001");
|
||||
INFO("outputing payload:" << payload)
|
||||
INFO("outputing payload:" << payload);
|
||||
std::string json = payload.substr(json_start);
|
||||
nlohmann::json j = nlohmann::json::parse(json);
|
||||
CHECK(j["desc"].get<std::string>() == "Bin of 100 bytes");
|
||||
INFO("outputing payload desc::" << j["desc"].get<std::string>())
|
||||
INFO("outputing payload desc::" << j["desc"].get<std::string>());
|
||||
CHECK((bool)j["bin1"]["_placeholder"]);
|
||||
INFO("outputing payload bin1:" << j["bin1"].dump())
|
||||
INFO("outputing payload bin1:" << j["bin1"].dump());
|
||||
CHECK((bool)j["bin2"]["_placeholder"]);
|
||||
INFO("outputing payload bin2:" << j["bin2"].dump())
|
||||
INFO("outputing payload bin2:" << j["bin2"].dump());
|
||||
int bin1Num = j["bin1"]["num"].get<int>();
|
||||
char numchar[] = {0,0};
|
||||
numchar[0] = bin1Num+'0';
|
||||
CHECK(buffers[bin1Num]->length()==100);
|
||||
INFO("outputing payload bin1 num:" << numchar)
|
||||
INFO("outputing payload bin1 num:" << numchar);
|
||||
CHECK(buffers[bin1Num]->at(50)==0);
|
||||
CHECK(buffers[bin1Num]->at(0) == 0);
|
||||
int bin2Num = j["bin2"]["num"].get<int>();
|
||||
numchar[0] = bin2Num+'0';
|
||||
CHECK(buffers[bin2Num]->length()==50);
|
||||
INFO("outputing payload bin2 num:" << numchar)
|
||||
INFO("outputing payload bin2 num:" << numchar);
|
||||
CHECK(buffers[bin2Num]->at(25)==1);
|
||||
CHECK(buffers[bin2Num]->at(0) == 1);
|
||||
}
|
||||
@ -210,7 +209,8 @@ TEST_CASE( "test_packet_parse_4" )
|
||||
bool hasbin = p.parse("452-/nsp,101[\"bin_event\",[{\"_placeholder\":true,\"num\":1},{\"_placeholder\":true,\"num\":0},\"text\"]]");
|
||||
CHECK(hasbin);
|
||||
char buf[100];
|
||||
memset(buf,0,100);
|
||||
buf[0] = packet::frame_message;
|
||||
memset(buf + 1,0,99);
|
||||
|
||||
std::string bufstr(buf,100);
|
||||
std::string bufstr2(buf,50);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user