From 000c1332e30396ffa9b1c4a54444a0da38e43620 Mon Sep 17 00:00:00 2001 From: chenguoping Date: Mon, 22 Jun 2020 19:58:57 +0800 Subject: [PATCH 1/4] fix compiler error C2440 in VS --- test/src/unit-conversions.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/src/unit-conversions.cpp b/test/src/unit-conversions.cpp index 2fce369616..d966da4c9a 100644 --- a/test/src/unit-conversions.cpp +++ b/test/src/unit-conversions.cpp @@ -1746,7 +1746,8 @@ TEST_CASE("std::optional") std::vector> opt_array = {{1, 2, std::nullopt}}; CHECK(json(opt_array) == j_array); - CHECK(std::vector>(j_array) == opt_array); + std::vector> tmp = j_array; + CHECK(tmp == opt_array); } SECTION("object") @@ -1755,7 +1756,8 @@ TEST_CASE("std::optional") std::map> opt_object {{"one", 1}, {"two", 2}, {"zero", std::nullopt}}; CHECK(json(opt_object) == j_object); - CHECK(std::map>(j_object) == opt_object); + std::map> tmp =j_object; + CHECK(tmp == opt_object); } } #endif From 4c4af3b161521a3ed84f455f767e8524d5f80a80 Mon Sep 17 00:00:00 2001 From: chenguoping Date: Wed, 24 Jun 2020 09:27:08 +0800 Subject: [PATCH 2/4] add travis task : run testcases in C++17 --- .travis.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 280c2c06c0..480797095a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -218,6 +218,17 @@ matrix: sources: ['ubuntu-toolchain-r-test'] packages: ['g++-9', 'ninja-build'] + - os: linux + compiler: gcc + env: + - COMPILER=g++-9 + - CXXFLAGS=-std=c++17 + - CMAKECXXSTANDARD=17 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-9', 'ninja-build'] + # Linux / Clang - os: linux @@ -328,7 +339,11 @@ script: # compile and execute unit tests - mkdir -p build && cd build - - cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -GNinja && cmake --build . --config Release + - if [[ "${CMAKECXXSTANDARD}" != "" ]]; then + cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -DCMAKE_CXX_STANDARD=${CMAKECXXSTANDARD} -GNinja && cmake --build . --config Release ; + else + cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -GNinja && cmake --build . --config Release ; + fi - ctest -C Release --timeout 2700 -V -j - cd .. From e0f6c96c194c97ff9eb749979216c2d4da173067 Mon Sep 17 00:00:00 2001 From: chenguoping Date: Wed, 24 Jun 2020 15:18:13 +0800 Subject: [PATCH 3/4] detect the exception in testcase - SECTION("null") --- test/src/unit-conversions.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/src/unit-conversions.cpp b/test/src/unit-conversions.cpp index d966da4c9a..476a2149d9 100644 --- a/test/src/unit-conversions.cpp +++ b/test/src/unit-conversions.cpp @@ -1710,7 +1710,8 @@ TEST_CASE("std::optional") std::optional opt_null; CHECK(json(opt_null) == j_null); - CHECK(std::optional(j_null) == std::nullopt); + CHECK_THROWS_WITH(std::optional(j_null) == std::nullopt, + "[json.exception.type_error.302] type must be string, but is null"); } SECTION("string") From 7df758f41f97a43d1b562579bd260fee94187b9d Mon Sep 17 00:00:00 2001 From: chenguoping Date: Sun, 28 Jun 2020 09:26:33 +0800 Subject: [PATCH 4/4] rename CMAKECXXSTANDARD by CMAKE_CXX_STANDARD --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 480797095a..d5811eebd8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -223,7 +223,7 @@ matrix: env: - COMPILER=g++-9 - CXXFLAGS=-std=c++17 - - CMAKECXXSTANDARD=17 + - CMAKE_CXX_STANDARD=17 addons: apt: sources: ['ubuntu-toolchain-r-test'] @@ -339,8 +339,8 @@ script: # compile and execute unit tests - mkdir -p build && cd build - - if [[ "${CMAKECXXSTANDARD}" != "" ]]; then - cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -DCMAKE_CXX_STANDARD=${CMAKECXXSTANDARD} -GNinja && cmake --build . --config Release ; + - if [[ "${CMAKE_CXX_STANDARD}" != "" ]]; then + cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} -GNinja && cmake --build . --config Release ; else cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -GNinja && cmake --build . --config Release ; fi