From 7e614099972670c0e3455744a6e8c7b3f6dcb2a8 Mon Sep 17 00:00:00 2001 From: Jochen Ulrich Date: Tue, 21 Jul 2020 17:06:56 +0200 Subject: [PATCH 1/8] Updates GTest --- tests/CMakeLists.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4c2392b..40babf5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,8 +4,8 @@ cmake_minimum_required(VERSION 3.0) include("cmake/HunterGate.cmake") HunterGate( - URL "https://github.com/ruslo/hunter/archive/v0.23.28.tar.gz" - SHA1 "6c79b36253a8e8bcba48927e9f3be65a3a81e6ec" + URL "https://github.com/cpp-pm/hunter/archive/v0.23.262.tar.gz" + SHA1 "eb51e633e08cdbe2153caf255e9c23968fecb29d" ) project(HttpStatusCodesTests) @@ -20,7 +20,7 @@ enable_testing() include_directories(${PROJECT_SOURCE_DIR}/..) add_executable(CVariantTest CVariantTest.cpp) -target_link_libraries(CVariantTest GTest::main) +target_link_libraries(CVariantTest GTest::gtest_main) add_test(NAME CVariantTest COMMAND CVariantTest) add_executable(CVariantCompileTest CVariantCompileTest.c) @@ -32,7 +32,7 @@ set_target_properties(CVariantCompileTest PROPERTIES ) add_executable(C++VariantTest C++VariantTest.cpp) -target_link_libraries(C++VariantTest GTest::main) +target_link_libraries(C++VariantTest GTest::gtest_main) add_test(NAME C++VariantTest COMMAND C++VariantTest) set_target_properties(C++VariantTest PROPERTIES CXX_STANDARD 98 @@ -49,7 +49,7 @@ endif() if(CXX_SUPPORTS_STRONG_ENUMS) add_executable(C++11VariantTest C++11VariantTest.cpp) - target_link_libraries(C++11VariantTest GTest::main) + target_link_libraries(C++11VariantTest GTest::gtest_main) add_test(NAME C++11VariantTest COMMAND C++11VariantTest) set_target_properties(C++11VariantTest PROPERTIES CXX_STANDARD 11 @@ -88,6 +88,9 @@ endif() if (QTCORE_LIB) add_executable(QtVariantTest QtVariantTest.cpp "${PROJECT_SOURCE_DIR}/../HttpStatusCodes_Qt.h") - target_link_libraries(QtVariantTest GTest::main ${QTCORE_LIB} ${QTNETWORK_LIB}) + target_link_libraries(QtVariantTest GTest::gtest_main ${QTCORE_LIB} ${QTNETWORK_LIB}) add_test(NAME QtVariantTest COMMAND QtVariantTest) + if (WIN32) + set_tests_properties( QtVariantTest PROPERTIES ENVIRONMENT "PATH=$;$ENV{PATH}" ) + endif() endif() From 15e9c36d0b3715165eda243996d15387df6432e2 Mon Sep 17 00:00:00 2001 From: Jochen Ulrich Date: Tue, 21 Jul 2020 17:18:20 +0200 Subject: [PATCH 2/8] Switch GTest to version 1.8.1 for C++98 support --- tests/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 40babf5..d836b4a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,8 +4,8 @@ cmake_minimum_required(VERSION 3.0) include("cmake/HunterGate.cmake") HunterGate( - URL "https://github.com/cpp-pm/hunter/archive/v0.23.262.tar.gz" - SHA1 "eb51e633e08cdbe2153caf255e9c23968fecb29d" + URL "https://github.com/cpp-pm/hunter/archive/v0.23.224.tar.gz" + SHA1 "18e57a43efc435f2e1dae1291e82e42afbf940be" ) project(HttpStatusCodesTests) From b14a8b3db3a938e5a0417453e8654d698dbf79e0 Mon Sep 17 00:00:00 2001 From: Jochen Ulrich Date: Tue, 21 Jul 2020 17:40:15 +0200 Subject: [PATCH 3/8] Updates changelog --- CHANGELOG.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79515dd..b0ea73d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ -# Changelog # {#changelog} +# Changelog # -\brief The changelog of the http-status-codes library. +The changelog of the http-status-codes library. This project adheres to [Semantic Versioning](http://semver.org/). @@ -10,6 +10,16 @@ This changelog follows the [Keep a Changelog](http://keepachangelog.com) format. --- +## Unreleased ## + +### Changed ### + +- [#12] Updated GTest to 1.8.1 to fix deprecation warnings with recent compilers. + + +--- + + ## [1.3.0] - 2019-02-21 ## ### Added ### @@ -64,6 +74,7 @@ Initial (actually unversioned) release. --- +[1.3.0]: https://github.com/j-ulrich/http-status-codes-cpp/releases/tag/1.3.0 [1.2.0]: https://github.com/j-ulrich/http-status-codes-cpp/releases/tag/1.2.0 [1.1.1]: https://github.com/j-ulrich/http-status-codes-cpp/releases/tag/1.1.1 [1.1.0]: https://github.com/j-ulrich/http-status-codes-cpp/releases/tag/1.1.0 From 563635cce5a5d37709ff617411f35114bb3fe456 Mon Sep 17 00:00:00 2001 From: Jochen Ulrich Date: Wed, 22 Jul 2020 14:14:14 +0200 Subject: [PATCH 4/8] Updates coding style in readme --- README.md | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 0e5ad24..922e4bd 100644 --- a/README.md +++ b/README.md @@ -46,12 +46,12 @@ Might also be working with Qt 4 versions but this has not been tested. #include "HttpStatusCodes_C++.h" #include -void printReplyStatus(MyHttpReplyClass reply) +void printReplyStatus( MyHttpReplyClass reply ) { - if (reply.status == HttpStatus::OK) + if ( reply.status == HttpStatus::OK ) std::cout << "Success!"; else - std::cerr << reply.status << " " << HttpStatus::reasonPhrase(reply.status); + std::cerr << reply.status << " " << HttpStatus::reasonPhrase( reply.status ); } ``` @@ -107,17 +107,17 @@ enum Code ##### C Variant ##### ```c -char HttpStatus_isInformational(int code); -char HttpStatus_isSuccessful(int code); -char HttpStatus_isRedirection(int code); -char HttpStatus_isClientError(int code); -char HttpStatus_isServerError(int code); +char HttpStatus_isInformational( int code ); +char HttpStatus_isSuccessful( int code ); +char HttpStatus_isRedirection( int code ); +char HttpStatus_isClientError( int code ); +char HttpStatus_isServerError( int code ); ``` Return `1` if the given _code_ belongs to the corresponding class of status codes (see [RFC7231](https://tools.ietf.org/html/rfc7231#section-6)). Return `0` otherwise. ```c -char HttpStatus_isError(int code); +char HttpStatus_isError( int code); ``` Returns `1` if the given _code_ is either a client error, a server error or any non-standard error code. Non-standard error codes are status codes with a value of 600 or higher. @@ -127,11 +127,11 @@ Returns `0` otherwise. > **Note:** The C++11 variant also provides overloads for `HttpStatus::Code`. So there is no need to cast. ```c++ -bool HttpStatus::isInformational(int code); -bool HttpStatus::isSuccessful(int code); -bool HttpStatus::isRedirection(int code); -bool HttpStatus::isClientError(int code); -bool HttpStatus::isServerError(int code); +bool HttpStatus::isInformational( int code ); +bool HttpStatus::isSuccessful( int code ); +bool HttpStatus::isRedirection( int code ); +bool HttpStatus::isClientError( int code ); +bool HttpStatus::isServerError( int code ); ``` Return `true` if the given _code_ belongs to the corresponding class of status codes (see [RFC7231](https://tools.ietf.org/html/rfc7231#section-6)). Return `false` otherwise. @@ -139,7 +139,7 @@ Return `false` otherwise. ```c++ -bool HttpStatus::isError(int code); +bool HttpStatus::isError( int code ); ``` Returns `true` if the given _code_ is either a client error, a server error or any non-standard error code. Non-standard error codes are status codes with a value of 600 or higher. @@ -150,20 +150,20 @@ Returns `false` otherwise. ##### C Variant ##### ```c -const char* HttpStatus_reasonPhrase(int code); +const char* HttpStatus_reasonPhrase( int code ); ``` Returns the HTTP reason phrase string corresponding to the given _code_. ##### C++/C++11 Variants ##### > **Note:** The C++11 variant also provides an overload for `HttpStatus::Code`. So there is no need to cast. ```c++ -std::string HttpStatus::reasonPhrase(int code); +std::string HttpStatus::reasonPhrase( int code ); ``` Returns the HTTP reason phrase string corresponding to the given _code_. ##### Qt Variant ##### ```c++ -QString HttpStatus::reasonPhrase(int code); +QString HttpStatus::reasonPhrase( int code ); ``` Returns the HTTP reason phrase string corresponding to the given _code_. @@ -172,20 +172,20 @@ Returns the HTTP reason phrase string corresponding to the given _code_. ##### C++11 Variant ##### ```c++ -int HttpStatus::toInt(HttpStatus::Code code); +int HttpStatus::toInt( HttpStatus::Code code ); ``` Returns the integer value corresponding to a given a _code_. This is a convenience function as replacement for a `static_cast()`. ##### Qt Variant ##### ```c++ -int HttpStatus::networkErrorToStatusCode(QNetworkReply::NetworkError error); +int HttpStatus::networkErrorToStatusCode( QNetworkReply::NetworkError error ); ``` Returns the HTTP status code corresponding to the given _error_ if there is one. Otherwise, `-1` is returned. ```c++ -QNetworkReply::NetworkError HttpStatus::statusCodeToNetworkError(int code); +QNetworkReply::NetworkError HttpStatus::statusCodeToNetworkError( int code ); ``` Returns the `QNetworkReply::NetworkError` corresponding to the given _code_ if there is one. For codes where there is no exact match, the best matching "catch all" code (`QNetworkReply::NoError`, From a240a38f672565a8919e02f29c98acd05ed6e211 Mon Sep 17 00:00:00 2001 From: Jochen Ulrich Date: Wed, 22 Jul 2020 14:29:19 +0200 Subject: [PATCH 5/8] Switches to Qt 5.12 on AppVeyor --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index e5f9301..f42577d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -4,7 +4,7 @@ environment: CTEST_OUTPUT_ON_FAILURE: '1' matrix: - CMAKE_GENERATOR: Visual Studio 15 2017 Win64 - QT_DIR: C:\Qt\5.11\msvc2017_64 + QT_DIR: C:\Qt\5.12\msvc2017_64 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 VCVARS_COMMANDLINE: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"' - CMAKE_GENERATOR: Visual Studio 14 2015 From 75a24881b360ce3a859d52621c38e8ff6877fb78 Mon Sep 17 00:00:00 2001 From: Jochen Ulrich Date: Wed, 22 Jul 2020 15:20:08 +0200 Subject: [PATCH 6/8] Reverts back to GTest 1.8.0 for older MSVC --- tests/CMakeLists.txt | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d836b4a..8dd8b26 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -3,10 +3,22 @@ cmake_minimum_required(VERSION 3.0) # Package Management using Hunter include("cmake/HunterGate.cmake") -HunterGate( - URL "https://github.com/cpp-pm/hunter/archive/v0.23.224.tar.gz" - SHA1 "18e57a43efc435f2e1dae1291e82e42afbf940be" -) +if ( WIN32 AND ( MSVC_TOOLSET_VERSION LESS 140 ) ) + # Visual Studio < 2015 + # GTest 1.8.0 + HunterGate( + URL "https://github.com/cpp-pm/hunter/archive/v0.23.222.tar.gz" + SHA1 "0b88baaa2a9a35b8ce632c57ade66be8dd918afd" + ) + set( GTEST_MAIN GTest::main ) +else() + # GTest 1.8.1 + HunterGate( + URL "https://github.com/cpp-pm/hunter/archive/v0.23.224.tar.gz" + SHA1 "18e57a43efc435f2e1dae1291e82e42afbf940be" + ) + set( GTEST_MAIN GTest::gtest_main ) +endif() project(HttpStatusCodesTests) @@ -20,7 +32,7 @@ enable_testing() include_directories(${PROJECT_SOURCE_DIR}/..) add_executable(CVariantTest CVariantTest.cpp) -target_link_libraries(CVariantTest GTest::gtest_main) +target_link_libraries(CVariantTest ${GTEST_MAIN}) add_test(NAME CVariantTest COMMAND CVariantTest) add_executable(CVariantCompileTest CVariantCompileTest.c) @@ -32,7 +44,7 @@ set_target_properties(CVariantCompileTest PROPERTIES ) add_executable(C++VariantTest C++VariantTest.cpp) -target_link_libraries(C++VariantTest GTest::gtest_main) +target_link_libraries(C++VariantTest ${GTEST_MAIN}) add_test(NAME C++VariantTest COMMAND C++VariantTest) set_target_properties(C++VariantTest PROPERTIES CXX_STANDARD 98 @@ -49,7 +61,7 @@ endif() if(CXX_SUPPORTS_STRONG_ENUMS) add_executable(C++11VariantTest C++11VariantTest.cpp) - target_link_libraries(C++11VariantTest GTest::gtest_main) + target_link_libraries(C++11VariantTest ${GTEST_MAIN}) add_test(NAME C++11VariantTest COMMAND C++11VariantTest) set_target_properties(C++11VariantTest PROPERTIES CXX_STANDARD 11 @@ -88,7 +100,7 @@ endif() if (QTCORE_LIB) add_executable(QtVariantTest QtVariantTest.cpp "${PROJECT_SOURCE_DIR}/../HttpStatusCodes_Qt.h") - target_link_libraries(QtVariantTest GTest::gtest_main ${QTCORE_LIB} ${QTNETWORK_LIB}) + target_link_libraries(QtVariantTest ${GTEST_MAIN} ${QTCORE_LIB} ${QTNETWORK_LIB}) add_test(NAME QtVariantTest COMMAND QtVariantTest) if (WIN32) set_tests_properties( QtVariantTest PROPERTIES ENVIRONMENT "PATH=$;$ENV{PATH}" ) From 2eccc8f86f746ad41d21c904c039ed2d031607f6 Mon Sep 17 00:00:00 2001 From: Jochen Ulrich Date: Wed, 22 Jul 2020 15:56:51 +0200 Subject: [PATCH 7/8] Updates HunterGate --- tests/cmake/HunterGate.cmake | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/tests/cmake/HunterGate.cmake b/tests/cmake/HunterGate.cmake index 8131cc9..246d214 100644 --- a/tests/cmake/HunterGate.cmake +++ b/tests/cmake/HunterGate.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2013-2018, Ruslan Baratov +# Copyright (c) 2013-2019, Ruslan Baratov # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -60,7 +60,7 @@ option(HUNTER_STATUS_PRINT "Print working status" ON) option(HUNTER_STATUS_DEBUG "Print a lot info" OFF) option(HUNTER_TLS_VERIFY "Enable/disable TLS certificate checking on downloads" ON) -set(HUNTER_WIKI "https://github.com/ruslo/hunter/wiki") +set(HUNTER_ERROR_PAGE "https://docs.hunter.sh/en/latest/reference/errors") function(hunter_gate_status_print) if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG) @@ -79,9 +79,9 @@ function(hunter_gate_status_debug) endif() endfunction() -function(hunter_gate_wiki wiki_page) - message("------------------------------ WIKI -------------------------------") - message(" ${HUNTER_WIKI}/${wiki_page}") +function(hunter_gate_error_page error_page) + message("------------------------------ ERROR ------------------------------") + message(" ${HUNTER_ERROR_PAGE}/${error_page}.html") message("-------------------------------------------------------------------") message("") message(FATAL_ERROR "") @@ -94,14 +94,13 @@ function(hunter_gate_internal_error) endforeach() message("[hunter ** INTERNAL **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") message("") - hunter_gate_wiki("error.internal") + hunter_gate_error_page("error.internal") endfunction() function(hunter_gate_fatal_error) - cmake_parse_arguments(hunter "" "WIKI" "" "${ARGV}") - string(COMPARE EQUAL "${hunter_WIKI}" "" have_no_wiki) - if(have_no_wiki) - hunter_gate_internal_error("Expected wiki") + cmake_parse_arguments(hunter "" "ERROR_PAGE" "" "${ARGV}") + if("${hunter_ERROR_PAGE}" STREQUAL "") + hunter_gate_internal_error("Expected ERROR_PAGE") endif() message("") foreach(x ${hunter_UNPARSED_ARGUMENTS}) @@ -109,11 +108,11 @@ function(hunter_gate_fatal_error) endforeach() message("[hunter ** FATAL ERROR **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") message("") - hunter_gate_wiki("${hunter_WIKI}") + hunter_gate_error_page("${hunter_ERROR_PAGE}") endfunction() function(hunter_gate_user_error) - hunter_gate_fatal_error(${ARGV} WIKI "error.incorrect.input.data") + hunter_gate_fatal_error(${ARGV} ERROR_PAGE "error.incorrect.input.data") endfunction() function(hunter_gate_self root version sha1 result) @@ -195,7 +194,7 @@ function(hunter_gate_detect_root) hunter_gate_fatal_error( "Can't detect HUNTER_ROOT" - WIKI "error.detect.hunter.root" + ERROR_PAGE "error.detect.hunter.root" ) endfunction() @@ -214,7 +213,7 @@ function(hunter_gate_download dir) "Settings:" " HUNTER_ROOT: ${HUNTER_GATE_ROOT}" " HUNTER_SHA1: ${HUNTER_GATE_SHA1}" - WIKI "error.run.install" + ERROR_PAGE "error.run.install" ) endif() string(COMPARE EQUAL "${dir}" "" is_bad) @@ -400,7 +399,7 @@ macro(HunterGate) hunter_gate_fatal_error( "Please set HunterGate *before* 'project' command. " "Detected project: ${PROJECT_NAME}" - WIKI "error.huntergate.before.project" + ERROR_PAGE "error.huntergate.before.project" ) endif() @@ -470,7 +469,7 @@ macro(HunterGate) "HUNTER_ROOT (${HUNTER_GATE_ROOT}) contains spaces." "Set HUNTER_ALLOW_SPACES_IN_PATH=ON to skip this error" "(Use at your own risk!)" - WIKI "error.spaces.in.hunter.root" + ERROR_PAGE "error.spaces.in.hunter.root" ) endif() endif() From 141ddefc67f406de9d9b073fcf0b4dfdb2ffa653 Mon Sep 17 00:00:00 2001 From: Jochen Ulrich Date: Wed, 22 Jul 2020 16:44:02 +0200 Subject: [PATCH 8/8] Fixes version selection of GTest --- tests/CMakeLists.txt | 28 +++++++++++----------------- tests/cmake/Hunter/config.cmake | 7 +++++++ 2 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 tests/cmake/Hunter/config.cmake diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8dd8b26..4148ab7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,23 +2,11 @@ cmake_minimum_required(VERSION 3.0) # Package Management using Hunter include("cmake/HunterGate.cmake") - -if ( WIN32 AND ( MSVC_TOOLSET_VERSION LESS 140 ) ) - # Visual Studio < 2015 - # GTest 1.8.0 - HunterGate( - URL "https://github.com/cpp-pm/hunter/archive/v0.23.222.tar.gz" - SHA1 "0b88baaa2a9a35b8ce632c57ade66be8dd918afd" - ) - set( GTEST_MAIN GTest::main ) -else() - # GTest 1.8.1 - HunterGate( - URL "https://github.com/cpp-pm/hunter/archive/v0.23.224.tar.gz" - SHA1 "18e57a43efc435f2e1dae1291e82e42afbf940be" - ) - set( GTEST_MAIN GTest::gtest_main ) -endif() +HunterGate( + URL "https://github.com/cpp-pm/hunter/archive/v0.23.224.tar.gz" + SHA1 "18e57a43efc435f2e1dae1291e82e42afbf940be" + LOCAL +) project(HttpStatusCodesTests) @@ -26,6 +14,12 @@ set (CMAKE_CXX_STANDARD 11) hunter_add_package(GTest) find_package(GTest CONFIG REQUIRED) +message( "GTest_VERSION: ${GTest_VERSION}" ) +if( GTest_VERSION VERSION_LESS "1.9.0" ) + set( GTEST_MAIN GTest::main ) +else() + set( GTEST_MAIN GTest::gtest_main ) +endif() enable_testing() diff --git a/tests/cmake/Hunter/config.cmake b/tests/cmake/Hunter/config.cmake new file mode 100644 index 0000000..031370d --- /dev/null +++ b/tests/cmake/Hunter/config.cmake @@ -0,0 +1,7 @@ + +if ( WIN32 AND ( MSVC_TOOLSET_VERSION LESS 140 ) ) + # Visual Studio < 2015 + hunter_config( GTest VERSION 1.8.0-hunter-p11 ) +else() + hunter_config( GTest VERSION 1.8.1 ) # Actually, this results in GTest version 1.9.0 +endif()