From 94b2b3f9ce761a92eb5c3791b56c953a92adf4ae Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Thu, 9 Feb 2023 18:57:34 +0100 Subject: [PATCH] Run all tests with C++11 enabled (#1820) --- README.md | 3 +- extras/tests/CMakeLists.txt | 3 +- extras/tests/Cpp11/CMakeLists.txt | 36 ------------------- extras/tests/FailingBuilds/CMakeLists.txt | 2 -- extras/tests/FailingBuilds/read_long_long.cpp | 4 --- extras/tests/JsonDocument/CMakeLists.txt | 1 + .../{Cpp11 => JsonDocument}/issue1120.cpp | 0 extras/tests/JsonVariant/CMakeLists.txt | 2 ++ .../tests/{Cpp11 => JsonVariant}/nullptr.cpp | 0 .../{Cpp11 => JsonVariant}/stl_containers.cpp | 0 .../tests/MixedConfiguration/CMakeLists.txt | 2 ++ .../use_long_long_0.cpp | 0 .../use_long_long_1.cpp | 0 extras/tests/Numbers/CMakeLists.txt | 3 -- 14 files changed, 8 insertions(+), 48 deletions(-) delete mode 100644 extras/tests/Cpp11/CMakeLists.txt rename extras/tests/{Cpp11 => JsonDocument}/issue1120.cpp (100%) rename extras/tests/{Cpp11 => JsonVariant}/nullptr.cpp (100%) rename extras/tests/{Cpp11 => JsonVariant}/stl_containers.cpp (100%) rename extras/tests/{Cpp11 => MixedConfiguration}/use_long_long_0.cpp (100%) rename extras/tests/{Cpp11 => MixedConfiguration}/use_long_long_1.cpp (100%) diff --git a/README.md b/README.md index 03c52f87..3e646131 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,8 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). * Supports [custom converters](https://arduinojson.org/news/2021/05/04/version-6-18-0/) * Portable * Usable on any C++ project (not limited to Arduino) - * Compatible with C++98, C++11, C++14 and C++17 + * Compatible with C++11, C++14 and C++17 + * Support for C++98/C++03 available on [ArduinoJson 6.20.x](https://github.com/bblanchon/ArduinoJson/tree/6.20.x) * Zero warnings with `-Wall -Wextra -pedantic` and `/W4` * [Header-only library](https://en.wikipedia.org/wiki/Header-only) * Works with virtually any board diff --git a/extras/tests/CMakeLists.txt b/extras/tests/CMakeLists.txt index faf4cd9a..d3b285ed 100644 --- a/extras/tests/CMakeLists.txt +++ b/extras/tests/CMakeLists.txt @@ -2,7 +2,7 @@ # Copyright © 2014-2022, Benoit BLANCHON # MIT License -set(CMAKE_CXX_STANDARD 98) +set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) add_subdirectory(catch) @@ -10,7 +10,6 @@ add_subdirectory(catch) link_libraries(ArduinoJson catch) include_directories(Helpers) -add_subdirectory(Cpp11) add_subdirectory(Cpp17) add_subdirectory(Cpp20) add_subdirectory(FailingBuilds) diff --git a/extras/tests/Cpp11/CMakeLists.txt b/extras/tests/Cpp11/CMakeLists.txt deleted file mode 100644 index 0b84a14c..00000000 --- a/extras/tests/Cpp11/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -# ArduinoJson - https://arduinojson.org -# Copyright © 2014-2022, Benoit BLANCHON -# MIT License - -if("cxx_nullptr" IN_LIST CMAKE_CXX_COMPILE_FEATURES) - list(APPEND SOURCES nullptr.cpp) - add_definitions(-DARDUINOJSON_HAS_NULLPTR=1) -endif() - -if("cxx_auto_type" IN_LIST CMAKE_CXX_COMPILE_FEATURES AND "cxx_constexpr" IN_LIST CMAKE_CXX_COMPILE_FEATURES) - list(APPEND SOURCES issue1120.cpp) -endif() - -if("cxx_long_long_type" IN_LIST CMAKE_CXX_COMPILE_FEATURES) - list(APPEND SOURCES use_long_long_0.cpp use_long_long_1.cpp) -endif() - -if("cxx_range_for" IN_LIST CMAKE_CXX_COMPILE_FEATURES AND "cxx_generalized_initializers" IN_LIST CMAKE_CXX_COMPILE_FEATURES) - list(APPEND SOURCES stl_containers.cpp) -endif() - -if(NOT SOURCES) - return() -endif() - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -add_executable(Cpp11Tests ${SOURCES}) - -add_test(Cpp11 Cpp11Tests) - -set_tests_properties(Cpp11 - PROPERTIES - LABELS "Catch" -) diff --git a/extras/tests/FailingBuilds/CMakeLists.txt b/extras/tests/FailingBuilds/CMakeLists.txt index dc76c910..1ddab769 100644 --- a/extras/tests/FailingBuilds/CMakeLists.txt +++ b/extras/tests/FailingBuilds/CMakeLists.txt @@ -31,11 +31,9 @@ add_executable(Issue1189 Issue1189.cpp) build_should_fail(Issue1189) add_executable(read_long_long read_long_long.cpp) -set_property(TARGET read_long_long PROPERTY CXX_STANDARD 11) build_should_fail(read_long_long) add_executable(write_long_long write_long_long.cpp) -set_property(TARGET write_long_long PROPERTY CXX_STANDARD 11) build_should_fail(write_long_long) add_executable(delete_jsondocument delete_jsondocument.cpp) diff --git a/extras/tests/FailingBuilds/read_long_long.cpp b/extras/tests/FailingBuilds/read_long_long.cpp index d900a7f3..da4516f1 100644 --- a/extras/tests/FailingBuilds/read_long_long.cpp +++ b/extras/tests/FailingBuilds/read_long_long.cpp @@ -9,10 +9,6 @@ # error This test requires sizeof(long) < 8 #endif -#if !ARDUINOJSON_HAS_LONG_LONG -# error This test requires C++11 -#endif - ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(long long) int main() { DynamicJsonDocument doc(1024); diff --git a/extras/tests/JsonDocument/CMakeLists.txt b/extras/tests/JsonDocument/CMakeLists.txt index 53567803..781d128f 100644 --- a/extras/tests/JsonDocument/CMakeLists.txt +++ b/extras/tests/JsonDocument/CMakeLists.txt @@ -12,6 +12,7 @@ add_executable(JsonDocumentTests DynamicJsonDocument.cpp ElementProxy.cpp isNull.cpp + issue1120.cpp MemberProxy.cpp nesting.cpp overflowed.cpp diff --git a/extras/tests/Cpp11/issue1120.cpp b/extras/tests/JsonDocument/issue1120.cpp similarity index 100% rename from extras/tests/Cpp11/issue1120.cpp rename to extras/tests/JsonDocument/issue1120.cpp diff --git a/extras/tests/JsonVariant/CMakeLists.txt b/extras/tests/JsonVariant/CMakeLists.txt index 1a0d14a9..3f37a11b 100644 --- a/extras/tests/JsonVariant/CMakeLists.txt +++ b/extras/tests/JsonVariant/CMakeLists.txt @@ -16,12 +16,14 @@ add_executable(JsonVariantTests memoryUsage.cpp misc.cpp nesting.cpp + nullptr.cpp or.cpp overflow.cpp remove.cpp set.cpp shallowCopy.cpp size.cpp + stl_containers.cpp subscript.cpp types.cpp unbound.cpp diff --git a/extras/tests/Cpp11/nullptr.cpp b/extras/tests/JsonVariant/nullptr.cpp similarity index 100% rename from extras/tests/Cpp11/nullptr.cpp rename to extras/tests/JsonVariant/nullptr.cpp diff --git a/extras/tests/Cpp11/stl_containers.cpp b/extras/tests/JsonVariant/stl_containers.cpp similarity index 100% rename from extras/tests/Cpp11/stl_containers.cpp rename to extras/tests/JsonVariant/stl_containers.cpp diff --git a/extras/tests/MixedConfiguration/CMakeLists.txt b/extras/tests/MixedConfiguration/CMakeLists.txt index 01d1216e..791a7a62 100644 --- a/extras/tests/MixedConfiguration/CMakeLists.txt +++ b/extras/tests/MixedConfiguration/CMakeLists.txt @@ -19,6 +19,8 @@ add_executable(MixedConfigurationTests issue1707.cpp use_double_0.cpp use_double_1.cpp + use_long_long_0.cpp + use_long_long_1.cpp ) set_target_properties(MixedConfigurationTests PROPERTIES UNITY_BUILD OFF) diff --git a/extras/tests/Cpp11/use_long_long_0.cpp b/extras/tests/MixedConfiguration/use_long_long_0.cpp similarity index 100% rename from extras/tests/Cpp11/use_long_long_0.cpp rename to extras/tests/MixedConfiguration/use_long_long_0.cpp diff --git a/extras/tests/Cpp11/use_long_long_1.cpp b/extras/tests/MixedConfiguration/use_long_long_1.cpp similarity index 100% rename from extras/tests/Cpp11/use_long_long_1.cpp rename to extras/tests/MixedConfiguration/use_long_long_1.cpp diff --git a/extras/tests/Numbers/CMakeLists.txt b/extras/tests/Numbers/CMakeLists.txt index 05e1e894..f7cf6616 100644 --- a/extras/tests/Numbers/CMakeLists.txt +++ b/extras/tests/Numbers/CMakeLists.txt @@ -2,9 +2,6 @@ # Copyright © 2014-2022, Benoit BLANCHON # MIT License -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED OFF) - add_executable(NumbersTests convertNumber.cpp parseFloat.cpp