diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml
index 7eaedd73c..f33cbf903 100644
--- a/.github/workflows/macos.yml
+++ b/.github/workflows/macos.yml
@@ -26,6 +26,8 @@ jobs:
- uses: actions/checkout@v3
- name: Run CMake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
+ - name: Print JSON meta
+ run: cmake --build build --target print_meta --parallel 10
- name: Build
run: cmake --build build --parallel 10
- name: Test
@@ -43,6 +45,8 @@ jobs:
- uses: actions/checkout@v3
- name: Run CMake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
+ - name: Print JSON meta
+ run: cmake --build build --target print_meta --parallel 10
- name: Build
run: cmake --build build --parallel 10
- name: Test
@@ -60,6 +64,8 @@ jobs:
- uses: actions/checkout@v3
- name: Run CMake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_TestStandards=${{ matrix.standard }}
+ - name: Print JSON meta
+ run: cmake --build build --target print_meta --parallel 10
- name: Build
run: cmake --build build --parallel 10
- name: Test
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
index fb4b893d6..63845de3e 100644
--- a/.github/workflows/windows.yml
+++ b/.github/workflows/windows.yml
@@ -49,6 +49,8 @@ jobs:
# platform: ${{ matrix.architecture }}
- name: Run CMake
run: cmake -S . -B build -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
+ - name: Print JSON meta
+ run: cmake --build build --target print_meta --parallel 10
- name: Build
run: cmake --build build --parallel 10
- name: Test
@@ -69,6 +71,8 @@ jobs:
- name: Run CMake
run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="/W4 /WX"
if: matrix.build_type == 'Debug'
+ - name: Print JSON meta
+ run: cmake --build build --config ${{ matrix.build_type }} --target print_meta --parallel 10
- name: Build
run: cmake --build build --config ${{ matrix.build_type }} --parallel 10
- name: Test
@@ -81,6 +85,8 @@ jobs:
- uses: actions/checkout@v3
- name: Run CMake
run: cmake -S . -B build -G "Visual Studio 16 2019" -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX"
+ - name: Print JSON meta
+ run: cmake --build build --config Release --target print_meta --parallel 10
- name: Build
run: cmake --build build --config Release --parallel 10
- name: Test
@@ -101,6 +107,8 @@ jobs:
- name: Run CMake
run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="/W4 /WX"
if: matrix.build_type == 'Debug'
+ - name: Print JSON meta
+ run: cmake --build build --config ${{ matrix.build_type }} --target print_meta --parallel 10
- name: Build
run: cmake --build build --config ${{ matrix.build_type }} --parallel 10
- name: Test
@@ -113,6 +121,8 @@ jobs:
- uses: actions/checkout@v3
- name: Run CMake
run: cmake -S . -B build -G "Visual Studio 17 2022" -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX"
+ - name: Print JSON meta
+ run: cmake --build build --config Release --target print_meta --parallel 10
- name: Build
run: cmake --build build --config Release --parallel 10
- name: Test
@@ -130,6 +140,8 @@ jobs:
run: curl -fsSL -o LLVM${{ matrix.version }}.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ matrix.version }}.0.0/LLVM-${{ matrix.version }}.0.0-win64.exe ; 7z x LLVM${{ matrix.version }}.exe -y -o"C:/Program Files/LLVM"
- name: Run CMake
run: cmake -S . -B build -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
+ - name: Print JSON meta
+ run: cmake --build build --target print_meta --parallel 10
- name: Build
run: cmake --build build --parallel 10
- name: Test
@@ -145,6 +157,8 @@ jobs:
- uses: actions/checkout@v3
- name: Run CMake
run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -T ClangCL -DJSON_BuildTests=On
+ - name: Print JSON meta
+ run: cmake --build build --target print_meta --parallel 10
- name: Build
run: cmake --build build --config Debug --parallel 10
- name: Test
diff --git a/cmake/ci.cmake b/cmake/ci.cmake
index 22cf09093..40f84b7dc 100644
--- a/cmake/ci.cmake
+++ b/cmake/ci.cmake
@@ -413,23 +413,27 @@ set(GCC_CXXFLAGS
-Wzero-length-bounds
)
+set(binary_dir ${PROJECT_BINARY_DIR}/build_gcc)
add_custom_target(ci_test_gcc
COMMAND CXX=${GCC_TOOL} CXXFLAGS="${GCC_CXXFLAGS}" ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_gcc
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_gcc
- COMMAND cd ${PROJECT_BINARY_DIR}/build_gcc && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir} -t print_meta
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
+ COMMAND cd ${binary_dir} && ${CMAKE_CTEST_COMMAND} -j${N} --output-on-failure
COMMENT "Compile and test with GCC using maximal warning flags"
)
+set(binary_dir ${PROJECT_BINARY_DIR}/build_clang)
add_custom_target(ci_test_clang
COMMAND CXX=${CLANG_TOOL} CXXFLAGS="${CLANG_CXXFLAGS}" ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_clang
- COMMAND cd ${PROJECT_BINARY_DIR}/build_clang && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir} -t print_meta
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
+ COMMAND cd ${binary_dir} && ${CMAKE_CTEST_COMMAND} -j${N} --output-on-failure
COMMENT "Compile and test with Clang using maximal warning flags"
)
@@ -438,25 +442,29 @@ add_custom_target(ci_test_clang
###############################################################################
foreach(CXX_STANDARD 11 14 17 20)
+ set(binary_dir ${PROJECT_BINARY_DIR}/build_gcc_cxx${CXX_STANDARD})
add_custom_target(ci_test_gcc_cxx${CXX_STANDARD}
COMMAND CXX=${GCC_TOOL} CXXFLAGS="${GCC_CXXFLAGS}" ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON -DJSON_FastTests=ON
-DJSON_TestStandards=${CXX_STANDARD}
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_gcc_cxx${CXX_STANDARD}
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_gcc_cxx${CXX_STANDARD}
- COMMAND cd ${PROJECT_BINARY_DIR}/build_gcc_cxx${CXX_STANDARD} && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir} -t print_meta
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
+ COMMAND cd ${binary_dir} && ${CMAKE_CTEST_COMMAND} -j${N} --output-on-failure
COMMENT "Compile and test with GCC for C++${CXX_STANDARD}"
)
+ set(binary_dir ${PROJECT_BINARY_DIR}/build_clang_cxx${CXX_STANDARD})
add_custom_target(ci_test_clang_cxx${CXX_STANDARD}
COMMAND CXX=${CLANG_TOOL} CXXFLAGS="${CLANG_CXXFLAGS}" ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON -DJSON_FastTests=ON
-DJSON_TestStandards=${CXX_STANDARD}
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang_cxx${CXX_STANDARD}
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_clang_cxx${CXX_STANDARD}
- COMMAND cd ${PROJECT_BINARY_DIR}/build_clang_cxx${CXX_STANDARD} && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir} -t print_meta
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
+ COMMAND cd ${binary_dir} && ${CMAKE_CTEST_COMMAND} -j${N} --output-on-failure
COMMENT "Compile and test with Clang for C++${CXX_STANDARD}"
)
endforeach()
@@ -465,13 +473,15 @@ endforeach()
# Disable exceptions.
###############################################################################
+set(binary_dir ${PROJECT_BINARY_DIR}/build_noexceptions)
add_custom_target(ci_test_noexceptions
COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND}
- -DCMAKE_BUILD_TYPE=Debug -GNinja
- -DJSON_BuildTests=ON -DCMAKE_CXX_FLAGS=-DJSON_NOEXCEPTION -DDOCTEST_TEST_FILTER=--no-throw
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_noexceptions
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_noexceptions
- COMMAND cd ${PROJECT_BINARY_DIR}/build_noexceptions && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure
+ -DCMAKE_BUILD_TYPE=Debug -GNinja
+ -DJSON_BuildTests=ON -DCMAKE_CXX_FLAGS=-DJSON_NOEXCEPTION -DDOCTEST_TEST_FILTER=--no-throw
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir} -t print_meta
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
+ COMMAND cd ${binary_dir} && ${CMAKE_CTEST_COMMAND} -j${N} --output-on-failure
COMMENT "Compile and test with exceptions switched off"
)
@@ -479,13 +489,15 @@ add_custom_target(ci_test_noexceptions
# Disable implicit conversions.
###############################################################################
+set(binary_dir ${PROJECT_BINARY_DIR}/build_noimplicitconversions)
add_custom_target(ci_test_noimplicitconversions
COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND}
- -DCMAKE_BUILD_TYPE=Debug -GNinja
- -DJSON_BuildTests=ON -DJSON_ImplicitConversions=OFF
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_noimplicitconversions
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_noimplicitconversions
- COMMAND cd ${PROJECT_BINARY_DIR}/build_noimplicitconversions && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure
+ -DCMAKE_BUILD_TYPE=Debug -GNinja
+ -DJSON_BuildTests=ON -DJSON_ImplicitConversions=OFF
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir} -t print_meta
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
+ COMMAND cd ${binary_dir} && ${CMAKE_CTEST_COMMAND} -j${N} --output-on-failure
COMMENT "Compile and test with implicit conversions switched off"
)
@@ -493,13 +505,15 @@ add_custom_target(ci_test_noimplicitconversions
# Enable improved diagnostics.
###############################################################################
+set(binary_dir ${PROJECT_BINARY_DIR}/build_diagnostics)
add_custom_target(ci_test_diagnostics
COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND}
- -DCMAKE_BUILD_TYPE=Debug -GNinja
- -DJSON_BuildTests=ON -DJSON_Diagnostics=ON
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_diagnostics
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_diagnostics
- COMMAND cd ${PROJECT_BINARY_DIR}/build_diagnostics && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure
+ -DCMAKE_BUILD_TYPE=Debug -GNinja
+ -DJSON_BuildTests=ON -DJSON_Diagnostics=ON
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir} -t print_meta
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
+ COMMAND cd ${binary_dir} && ${CMAKE_CTEST_COMMAND} -j${N} --output-on-failure
COMMENT "Compile and test with improved diagnostics enabled"
)
@@ -507,13 +521,15 @@ add_custom_target(ci_test_diagnostics
# Enable legacy discarded value comparison.
###############################################################################
+set(binary_dir ${PROJECT_BINARY_DIR}/build_legacycomparison)
add_custom_target(ci_test_legacycomparison
COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND}
- -DCMAKE_BUILD_TYPE=Debug -GNinja
- -DJSON_BuildTests=ON -DJSON_LegacyDiscardedValueComparison=ON
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_legacycomparison
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_legacycomparison
- COMMAND cd ${PROJECT_BINARY_DIR}/build_legacycomparison && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure
+ -DCMAKE_BUILD_TYPE=Debug -GNinja
+ -DJSON_BuildTests=ON -DJSON_LegacyDiscardedValueComparison=ON
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir} -t print_meta
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
+ COMMAND cd ${binary_dir} && ${CMAKE_CTEST_COMMAND} -j${N} --output-on-failure
COMMENT "Compile and test with legacy discarded value comparison enabled"
)
@@ -536,24 +552,26 @@ add_custom_target(ci_test_noglobaludls
# Coverage.
###############################################################################
+set(binary_dir ${PROJECT_BINARY_DIR}/build_coverage)
+set(binary_dir32 ${PROJECT_BINARY_DIR}/build_coverage32)
add_custom_target(ci_test_coverage
COMMAND CXX=g++ ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_FLAGS="--coverage;-fprofile-arcs;-ftest-coverage"
-DJSON_BuildTests=ON
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_coverage
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_coverage
- COMMAND cd ${PROJECT_BINARY_DIR}/build_coverage && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
+ COMMAND cd ${binary_dir} && ${CMAKE_CTEST_COMMAND} -j${N} --output-on-failure
COMMAND CXX=g++ ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_FLAGS="-m32;--coverage;-fprofile-arcs;-ftest-coverage"
-DJSON_BuildTests=ON -DJSON_32bitTest=ONLY
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_coverage32
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_coverage32
- COMMAND cd ${PROJECT_BINARY_DIR}/build_coverage32 && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir32}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir32}
+ COMMAND cd ${binary_dir32} && ${CMAKE_CTEST_COMMAND} -j${N} --output-on-failure
COMMAND ${LCOV_TOOL} --directory . --capture --output-file json.info --rc lcov_branch_coverage=1
COMMAND ${LCOV_TOOL} -e json.info ${SRC_FILES} --output-file json.info.filtered --rc lcov_branch_coverage=1
- COMMAND ${CMAKE_SOURCE_DIR}/tests/thirdparty/imapdl/filterbr.py json.info.filtered > json.info.filtered.noexcept
+ COMMAND ${PROJECT_SOURCE_DIR}/tests/thirdparty/imapdl/filterbr.py json.info.filtered > json.info.filtered.noexcept
COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.filtered.noexcept
COMMENT "Compile and test with coverage"
@@ -565,13 +583,14 @@ add_custom_target(ci_test_coverage
set(CLANG_CXX_FLAGS_SANITIZER "-g -O1 -fsanitize=address -fsanitize=undefined -fsanitize=integer -fsanitize=nullability -fno-omit-frame-pointer -fno-sanitize-recover=all -fno-sanitize=unsigned-integer-overflow -fno-sanitize=unsigned-shift-base")
+set(binary_dir ${PROJECT_BINARY_DIR}/build_clang_sanitizer)
add_custom_target(ci_test_clang_sanitizer
COMMAND CXX=${CLANG_TOOL} CXXFLAGS=${CLANG_CXX_FLAGS_SANITIZER} ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang_sanitizer
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_clang_sanitizer
- COMMAND cd ${PROJECT_BINARY_DIR}/build_clang_sanitizer && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
+ COMMAND cd ${binary_dir} && ${CMAKE_CTEST_COMMAND} -j${N} --output-on-failure
COMMENT "Compile and test with sanitizers"
)
@@ -607,13 +626,14 @@ add_custom_target(ci_test_amalgamation
# Build and test using the amalgamated header
###############################################################################
+set(binary_dir ${PROJECT_BINARY_DIR}/build_single_header)
add_custom_target(ci_test_single_header
COMMAND CXX=${GCC_TOOL} CXXFLAGS="${GCC_CXXFLAGS}" ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON -DJSON_MultipleHeaders=OFF -DJSON_FastTests=ON
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_single_header
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_single_header
- COMMAND cd ${PROJECT_BINARY_DIR}/build_single_header && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
+ COMMAND cd ${binary_dir} && ${CMAKE_CTEST_COMMAND} -j${N} --output-on-failure
COMMENT "Compile and test single-header version"
)
@@ -621,13 +641,14 @@ add_custom_target(ci_test_single_header
# Valgrind.
###############################################################################
+set(binary_dir ${PROJECT_BINARY_DIR}/build_valgrind)
add_custom_target(ci_test_valgrind
COMMAND CXX=${GCC_TOOL} ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON -DJSON_Valgrind=ON
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_valgrind
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_valgrind
- COMMAND cd ${PROJECT_BINARY_DIR}/build_valgrind && ${CMAKE_CTEST_COMMAND} -L valgrind --parallel ${N} --output-on-failure
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
+ COMMAND cd ${binary_dir} && ${CMAKE_CTEST_COMMAND} -L valgrind -j${N} --output-on-failure
COMMENT "Compile and test with Valgrind"
)
@@ -637,12 +658,13 @@ add_custom_target(ci_test_valgrind
set(CLANG_ANALYZER_CHECKS "fuchsia.HandleChecker,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,optin.cplusplus.UninitializedObject,optin.cplusplus.VirtualCall,optin.mpi.MPI-Checker,optin.osx.OSObjectCStyleCast,optin.osx.cocoa.localizability.EmptyLocalizationContextChecker,optin.osx.cocoa.localizability.NonLocalizedStringChecker,optin.performance.GCDAntipattern,optin.performance.Padding,optin.portability.UnixAPI,security.FloatLoopCounter,security.insecureAPI.DeprecatedOrUnsafeBufferHandling,security.insecureAPI.bcmp,security.insecureAPI.bcopy,security.insecureAPI.bzero,security.insecureAPI.rand,security.insecureAPI.strcpy,valist.CopyToSelf,valist.Uninitialized,valist.Unterminated,webkit.NoUncountedMemberChecker,webkit.RefCntblBaseVirtualDtor,core.CallAndMessage,core.DivideZero,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.VLASize,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.PlacementNew,cplusplus.PureVirtualCall,deadcode.DeadStores,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,osx.API,osx.MIG,osx.NumberObjectConversion,osx.OSObjectRetainCount,osx.ObjCProperty,osx.SecKeychainAPI,osx.cocoa.AtSync,osx.cocoa.AutoreleaseWrite,osx.cocoa.ClassRelease,osx.cocoa.Dealloc,osx.cocoa.IncompatibleMethodTypes,osx.cocoa.Loops,osx.cocoa.MissingSuperCall,osx.cocoa.NSAutoreleasePool,osx.cocoa.NSError,osx.cocoa.NilArg,osx.cocoa.NonNilReturnValue,osx.cocoa.ObjCGenerics,osx.cocoa.RetainCount,osx.cocoa.RunLoopAutoreleaseLeak,osx.cocoa.SelfInit,osx.cocoa.SuperDealloc,osx.cocoa.UnusedIvars,osx.cocoa.VariadicMethodTypes,osx.coreFoundation.CFError,osx.coreFoundation.CFNumber,osx.coreFoundation.CFRetainRelease,osx.coreFoundation.containers.OutOfBounds,osx.coreFoundation.containers.PointerSizedValues,security.insecureAPI.UncheckedReturn,security.insecureAPI.decodeValueOfObjCType,security.insecureAPI.getpw,security.insecureAPI.gets,security.insecureAPI.mkstemp,security.insecureAPI.mktemp,security.insecureAPI.vfork,unix.API,unix.Malloc,unix.MallocSizeof,unix.MismatchedDeallocator,unix.Vfork,unix.cstring.BadSizeArg,unix.cstring.NullArg")
+set(binary_dir ${PROJECT_BINARY_DIR}/build_clang_analyze)
add_custom_target(ci_clang_analyze
COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang_analyze
- COMMAND cd ${PROJECT_BINARY_DIR}/build_clang_analyze && ${SCAN_BUILD_TOOL} -enable-checker ${CLANG_ANALYZER_CHECKS} --use-c++=${CLANG_TOOL} -analyze-headers -o ${PROJECT_BINARY_DIR}/report ninja
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND cd ${binary_dir} && ${SCAN_BUILD_TOOL} -enable-checker ${CLANG_ANALYZER_CHECKS} --use-c++=${CLANG_TOOL} -analyze-headers -o ${PROJECT_BINARY_DIR}/report ninja
COMMENT "Check code with Clang Analyzer"
)
@@ -668,11 +690,12 @@ add_custom_target(ci_cpplint
# Check code with OCLint.
###############################################################################
-file(COPY ${PROJECT_SOURCE_DIR}/single_include/nlohmann/json.hpp DESTINATION ${PROJECT_BINARY_DIR}/src_single)
-file(RENAME ${PROJECT_BINARY_DIR}/src_single/json.hpp ${PROJECT_BINARY_DIR}/src_single/all.cpp)
-file(APPEND "${PROJECT_BINARY_DIR}/src_single/all.cpp" "\n\nint main()\n{}\n")
+set(binary_dir ${PROJECT_BINARY_DIR}/build_oclint)
+file(COPY ${PROJECT_SOURCE_DIR}/single_include/nlohmann/json.hpp DESTINATION ${binary_dir}/src_single/)
+file(RENAME ${binary_dir}/src_single/json.hpp ${binary_dir}/src_single/all.cpp)
+file(APPEND "${binary_dir}/src_single/all.cpp" "\n\nint main()\n{}\n")
-add_executable(single_all ${PROJECT_BINARY_DIR}/src_single/all.cpp)
+add_executable(single_all ${binary_dir}/src_single/all.cpp)
target_compile_features(single_all PRIVATE cxx_std_11)
add_custom_target(ci_oclint
@@ -680,15 +703,15 @@ add_custom_target(ci_oclint
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DJSON_BuildTests=OFF -DJSON_CI=ON
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_oclint
- COMMAND ${OCLINT_TOOL} -i ${PROJECT_BINARY_DIR}/build_oclint/src_single/all.cpp -p ${PROJECT_BINARY_DIR}/build_oclint --
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND ${OCLINT_TOOL} -i ${binary_dir}/src_single/all.cpp -p ${binary_dir} --
-report-type html -enable-global-analysis --max-priority-1=0 --max-priority-2=1000 --max-priority-3=2000
--disable-rule=MultipleUnaryOperator
--disable-rule=DoubleNegative
--disable-rule=ShortVariableName
--disable-rule=GotoStatement
--disable-rule=LongLine
- -o ${PROJECT_BINARY_DIR}/build_oclint/oclint_report.html
+ -o ${binary_dir}/oclint_report.html
COMMENT "Check code with OCLint"
)
@@ -696,13 +719,14 @@ add_custom_target(ci_oclint
# Check code with Clang-Tidy.
###############################################################################
+set(binary_dir ${PROJECT_BINARY_DIR}/build_clang_tidy)
add_custom_target(ci_clang_tidy
COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_CLANG_TIDY=${CLANG_TIDY_TOOL}
-DJSON_BuildTests=ON
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang_tidy
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_clang_tidy
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
COMMENT "Check code with Clang-Tidy"
)
@@ -710,14 +734,15 @@ add_custom_target(ci_clang_tidy
# Check code with PVS-Studio Analyzer .
###############################################################################
+set(binary_dir ${PROJECT_BINARY_DIR}/build_pvs_studio)
add_custom_target(ci_pvs_studio
COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DJSON_BuildTests=ON
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_pvs_studio
- COMMAND cd ${PROJECT_BINARY_DIR}/build_pvs_studio && ${PVS_STUDIO_ANALYZER_TOOL} analyze -j 10
- COMMAND cd ${PROJECT_BINARY_DIR}/build_pvs_studio && ${PLOG_CONVERTER_TOOL} -a'GA:1,2;64:1;CS' -t fullhtml PVS-Studio.log -o pvs
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND cd ${binary_dir} && ${PVS_STUDIO_ANALYZER_TOOL} analyze
+ COMMAND cd ${binary_dir} && ${PLOG_CONVERTER_TOOL} -a'GA:1,2;64:1;CS' -t fullhtml PVS-Studio.log -o pvs
COMMENT "Check code with PVS Studio"
)
@@ -725,10 +750,11 @@ add_custom_target(ci_pvs_studio
# Check code with Infer static analyzer.
###############################################################################
+set(binary_dir ${PROJECT_BINARY_DIR}/build_infer)
add_custom_target(ci_infer
- COMMAND mkdir -p ${PROJECT_BINARY_DIR}/build_infer
- COMMAND cd ${PROJECT_BINARY_DIR}/build_infer && ${INFER_TOOL} compile -- ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${PROJECT_SOURCE_DIR} -DJSON_BuildTests=ON
- COMMAND cd ${PROJECT_BINARY_DIR}/build_infer && ${INFER_TOOL} run -- make
+ COMMAND mkdir -p ${binary_dir}
+ COMMAND cd ${binary_dir} && ${INFER_TOOL} compile -- ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${PROJECT_SOURCE_DIR} -DJSON_BuildTests=ON
+ COMMAND cd ${binary_dir} && ${INFER_TOOL} run -- make
COMMENT "Check code with Infer"
)
@@ -736,15 +762,16 @@ add_custom_target(ci_infer
# Run test suite with previously downloaded test data.
###############################################################################
+set(binary_dir ${PROJECT_BINARY_DIR}/build_offline_testdata)
add_custom_target(ci_offline_testdata
- COMMAND mkdir -p ${PROJECT_BINARY_DIR}/build_offline_testdata/test_data
- COMMAND cd ${PROJECT_BINARY_DIR}/build_offline_testdata/test_data && ${GIT_TOOL} clone -c advice.detachedHead=false --branch v3.1.0 https://github.com/nlohmann/json_test_data.git --quiet --depth 1
+ COMMAND mkdir -p ${binary_dir}/test_data
+ COMMAND cd ${binary_dir}/test_data && ${GIT_TOOL} clone -c advice.detachedHead=false --branch v3.1.0 https://github.com/nlohmann/json_test_data.git --quiet --depth 1
COMMAND ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
- -DJSON_BuildTests=ON -DJSON_FastTests=ON -DJSON_TestDataDirectory=${PROJECT_BINARY_DIR}/build_offline_testdata/test_data/json_test_data
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_offline_testdata
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_offline_testdata
- COMMAND cd ${PROJECT_BINARY_DIR}/build_offline_testdata && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure
+ -DJSON_BuildTests=ON -DJSON_FastTests=ON -DJSON_TestDataDirectory=${binary_dir}/test_data/json_test_data
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
+ COMMAND cd ${binary_dir} && ${CMAKE_CTEST_COMMAND} -j${N} --output-on-failure
COMMENT "Check code with previously downloaded test data"
)
@@ -752,16 +779,17 @@ add_custom_target(ci_offline_testdata
# Run test suite when project was not checked out from Git
###############################################################################
+set(binary_dir ${PROJECT_BINARY_DIR}/build_non_git_tests)
add_custom_target(ci_non_git_tests
COMMAND git config --global --add safe.directory ${PROJECT_SOURCE_DIR}
- COMMAND mkdir -p ${PROJECT_BINARY_DIR}/build_non_git_tests/sources
+ COMMAND mkdir -p ${binary_dir}/sources
COMMAND cd ${PROJECT_SOURCE_DIR} && for FILE in `${GIT_TOOL} ls-tree --name-only HEAD`\; do cp -r $$FILE ${PROJECT_BINARY_DIR}/build_non_git_tests/sources \; done
COMMAND ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON -DJSON_FastTests=ON
- -S${PROJECT_BINARY_DIR}/build_non_git_tests/sources -B${PROJECT_BINARY_DIR}/build_non_git_tests
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_non_git_tests
- COMMAND cd ${PROJECT_BINARY_DIR}/build_non_git_tests && ${CMAKE_CTEST_COMMAND} --parallel ${N} -LE git_required --output-on-failure
+ -S${binary_dir}/sources -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
+ COMMAND cd ${binary_dir} && ${CMAKE_CTEST_COMMAND} -j${N} -LE git_required --output-on-failure
COMMENT "Check code when project was not checked out from Git"
)
@@ -769,13 +797,14 @@ add_custom_target(ci_non_git_tests
# Run test suite and exclude tests that change installed files
###############################################################################
+set(binary_dir ${PROJECT_BINARY_DIR}/build_reproducible_tests)
add_custom_target(ci_reproducible_tests
COMMAND ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON -DJSON_FastTests=ON
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_reproducible_tests
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_reproducible_tests
- COMMAND cd ${PROJECT_BINARY_DIR}/build_reproducible_tests && ${CMAKE_CTEST_COMMAND} --parallel ${N} -LE not_reproducible --output-on-failure
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
+ COMMAND cd ${binary_dir} && ${CMAKE_CTEST_COMMAND} -j${N} -LE not_reproducible --output-on-failure
COMMENT "Check code and exclude tests that change installed files"
)
@@ -812,12 +841,13 @@ add_custom_target(ci_single_binaries
# Benchmarks
###############################################################################
+set(binary_dir ${PROJECT_BINARY_DIR}/build_benchmarks)
add_custom_target(ci_benchmarks
COMMAND ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Release -GNinja
- -S${PROJECT_SOURCE_DIR}/benchmarks -B${PROJECT_BINARY_DIR}/build_benchmarks
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_benchmarks --target json_benchmarks
- COMMAND cd ${PROJECT_BINARY_DIR}/build_benchmarks && ./json_benchmarks
+ -S${PROJECT_SOURCE_DIR}/benchmarks -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir} --target json_benchmarks
+ COMMAND ${binary_dir}/json_benchmarks
COMMENT "Run benchmarks"
)
@@ -861,22 +891,24 @@ function(ci_add_cmake_flags_targets flag min_version)
string(TOLOWER "ci_cmake_flag_${flag}" flag_target)
string(REPLACE . _ min_version_var ${min_version})
set(cmake_binary ${CMAKE_${min_version_var}_BINARY})
+ set(binary_dir ${PROJECT_BINARY_DIR}/build_${flag_target})
add_custom_target(${flag_target}
COMMENT "Check CMake flag ${flag} (CMake ${CMAKE_VERSION})"
COMMAND ${CMAKE_COMMAND}
- -Werror=dev
- -D${flag}=ON
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_${flag_target}
+ -Werror=dev -D${flag}=ON
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
)
+ set(binary_dir_min_version ${PROJECT_BINARY_DIR}/build_${flag_target}_${min_version_var})
add_custom_target(${flag_target}_${min_version_var}
- COMMENT "Check CMake flag ${JSON_CMAKE_FLAG} (CMake ${min_version})"
- COMMAND mkdir -pv ${PROJECT_BINARY_DIR}/build_${flag_target}_${min_version_var}
- COMMAND cd ${PROJECT_BINARY_DIR}/build_${flag_target}_${min_version_var}
- && ${cmake_binary} -Werror=dev ${PROJECT_SOURCE_DIR} -D${flag}=ON
+ COMMENT "Check CMake flag ${flag} (CMake ${min_version})"
+ COMMAND mkdir -pv ${binary_dir_min_version}
+ COMMAND cd ${binary_dir_min_version} && ${cmake_binary}
+ -Werror=dev -D${flag}=ON
+ ${PROJECT_SOURCE_DIR}
DEPENDS ${cmake_binary}
)
list(APPEND JSON_CMAKE_FLAG_TARGETS ${JSON_CMAKE_FLAG_TARGET} ${flag_target}_${min_version_var})
- list(APPEND JSON_CMAKE_FLAG_BUILD_DIRS ${PROJECT_BINARY_DIR}/build_${flag_target} ${PROJECT_BINARY_DIR}/build_${flag_target}_${min_version_var})
+ list(APPEND JSON_CMAKE_FLAG_BUILD_DIRS ${binary_dir} ${binary_dir_min_version})
set(JSON_CMAKE_FLAG_TARGETS ${JSON_CMAKE_FLAG_TARGETS} PARENT_SCOPE)
set(JSON_CMAKE_FLAG_BUILD_DIRS ${JSON_CMAKE_FLAG_BUILD_DIRS} PARENT_SCOPE)
endfunction()
@@ -908,14 +940,16 @@ foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 g++-11 cla
unset(ADDITIONAL_FLAGS)
endif()
+ set(binary_dir ${PROJECT_BINARY_DIR}/build_compiler_${COMPILER})
add_custom_target(ci_test_compiler_${COMPILER}
COMMAND CXX=${COMPILER} ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON -DJSON_FastTests=ON
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_compiler_${COMPILER}
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
${ADDITIONAL_FLAGS}
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_compiler_${COMPILER}
- COMMAND cd ${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-unicode" --output-on-failure
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir} -t print_meta
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
+ COMMAND cd ${binary_dir} && ${CMAKE_CTEST_COMMAND} -j${N} -E "test-unicode" --output-on-failure
COMMENT "Compile and test with ${COMPILER}"
)
endif()
@@ -926,26 +960,29 @@ endforeach()
# CUDA example
###############################################################################
+set(binary_dir ${PROJECT_BINARY_DIR}/build_cuda_example)
add_custom_target(ci_cuda_example
COMMAND ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DCMAKE_CUDA_HOST_COMPILER=g++-8
- -S${PROJECT_SOURCE_DIR}/tests/cuda_example -B${PROJECT_BINARY_DIR}/build_cuda_example
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_cuda_example
+ -S${PROJECT_SOURCE_DIR}/tests/cuda_example -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
)
###############################################################################
# Intel C++ Compiler
###############################################################################
+set(binary_dir ${PROJECT_BINARY_DIR}/build_icpc)
add_custom_target(ci_icpc
COMMAND ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc
-DJSON_BuildTests=ON -DJSON_FastTests=ON
- -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_icpc
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_icpc
- COMMAND cd ${PROJECT_BINARY_DIR}/build_icpc && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-unicode" --output-on-failure
+ -S${PROJECT_SOURCE_DIR} -B${binary_dir}
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir} -t print_meta
+ COMMAND ${CMAKE_COMMAND} --build ${binary_dir}
+ COMMAND cd ${binary_dir} && ${CMAKE_CTEST_COMMAND} -j${N} -E "test-unicode" --output-on-failure
COMMENT "Compile and test with ICPC"
)
@@ -954,7 +991,7 @@ add_custom_target(ci_icpc
###############################################################################
add_custom_target(ci_test_documentation
- COMMAND make CXX="${GCC_TOOL}" check_output_portable -j8
+ COMMAND make CXX="${GCC_TOOL}" check_output_portable
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/docs
COMMENT "Check that all examples compile and create the desired output"
)
diff --git a/docs/examples/meta.output b/docs/examples/meta.output
index 43fe0a887..1dfa76e06 100644
--- a/docs/examples/meta.output
+++ b/docs/examples/meta.output
@@ -2,11 +2,32 @@
"compiler": {
"c++": "201103",
"family": "gcc",
- "version": "11.3.0"
+ "libc++": {
+ "family": "GNU libstdc++",
+ "version": 20220730
+ },
+ "version": "12.1.1"
+ },
+ "config": {
+ "JSON_DIAGNOSTICS": false,
+ "JSON_DISABLE_ENUM_SERIALIZATION": false,
+ "JSON_HAS_CPP_11": true,
+ "JSON_HAS_CPP_14": false,
+ "JSON_HAS_CPP_17": false,
+ "JSON_HAS_CPP_20": false,
+ "JSON_HAS_CPP_23": false,
+ "JSON_HAS_EXPERIMENTAL_FILESYSTEM": false,
+ "JSON_HAS_FILESYSTEM": false,
+ "JSON_HAS_THREE_WAY_COMPARISON": false,
+ "JSON_NOEXCEPTION": false,
+ "JSON_NO_IO": false,
+ "JSON_USE_IMPLICIT_CONVERSIONS": true,
+ "JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON": false,
+ "NLOHMANN_JSON_ABI_STRING": "json_v3_11_0"
},
"copyright": "(C) 2013-2022 Niels Lohmann",
"name": "JSON for Modern C++",
- "platform": "apple",
+ "platform": "linux",
"url": "https://github.com/nlohmann/json",
"version": {
"major": 3,
diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp
index ff739f5d5..b414ec64d 100644
--- a/include/nlohmann/detail/macro_scope.hpp
+++ b/include/nlohmann/detail/macro_scope.hpp
@@ -50,7 +50,11 @@
#ifdef __has_include
#if __has_include()
#include
+ #elif __has_include()
+ #include
#endif
+#else
+ #include
#endif
#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp
index 49188b314..011a1d7b9 100644
--- a/include/nlohmann/json.hpp
+++ b/include/nlohmann/json.hpp
@@ -247,9 +247,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
{
basic_json result;
- result["copyright"] = "(C) 2013-2022 Niels Lohmann";
result["name"] = "JSON for Modern C++";
- result["url"] = "https://github.com/nlohmann/json";
result["version"]["string"] =
detail::concat(std::to_string(NLOHMANN_JSON_VERSION_MAJOR), '.',
std::to_string(NLOHMANN_JSON_VERSION_MINOR), '.',
@@ -257,6 +255,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
result["version"]["major"] = NLOHMANN_JSON_VERSION_MAJOR;
result["version"]["minor"] = NLOHMANN_JSON_VERSION_MINOR;
result["version"]["patch"] = NLOHMANN_JSON_VERSION_PATCH;
+ result["url"] = "https://github.com/nlohmann/json";
+ result["copyright"] = "(C) 2013-2022 Niels Lohmann";
#ifdef _WIN32
result["platform"] = "win32";
@@ -281,12 +281,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
std::to_string(__GNUC_PATCHLEVEL__))
}
};
-#elif defined(__HP_cc) || defined(__HP_aCC)
- result["compiler"] = "hp"
+#elif defined(__HP_aCC)
+ result["compiler"] = {{"family", "hp"}, {"version", __HP_aCC}};
+#elif defined(__HP_cc)
+ result["compiler"] = {{"family", "hp"}, {"version", __HP_cc}};
#elif defined(__IBMCPP__)
result["compiler"] = {{"family", "ilecpp"}, {"version", __IBMCPP__}};
#elif defined(_MSC_VER)
- result["compiler"] = {{"family", "msvc"}, {"version", _MSC_VER}};
+ result["compiler"] = {{"family", "msvc"}, {"version", _MSC_VER}, {"version_full", _MSC_FULL_VER}};
#elif defined(__PGI)
result["compiler"] = {{"family", "pgcpp"}, {"version", __PGI}};
#elif defined(__SUNPRO_CC)
@@ -295,7 +297,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}};
#endif
-
#if defined(_MSVC_LANG)
result["compiler"]["c++"] = std::to_string(_MSVC_LANG);
#elif defined(__cplusplus)
@@ -303,6 +304,95 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
#else
result["compiler"]["c++"] = "unknown";
#endif
+
+ // see https://en.cppreference.com/w/cpp/header/ciso646
+#ifdef _LIBCPP_VERSION
+ result["compiler"]["libc++"] = {{"family", "LLVM libc++"}, {"version", _LIBCPP_VERSION}};
+#elif __GLIBCXX__ // Note: only version 6.1 or newer define this in ciso646
+ result["compiler"]["libc++"] = {{"family", "GNU libstdc++"}, {"version", __GLIBCXX__}};
+#elif _CPPLIB_VER
+ result["compiler"]["libc++"] = {{"family", "Microsoft STL"}, {"version", _CPPLIB_VER}};
+#else
+ result["compiler"]["libc++"] = {{"family", "unknown"}, {"version", "unknown"}};
+#endif
+
+ // NOLINTBEGIN(modernize-use-bool-literals)
+
+ result["config"]["JSON_DIAGNOSTICS"] =
+ static_cast(JSON_DIAGNOSTICS); // NOLINT(modernize-use-bool-literals)
+
+ result["config"]["JSON_DISABLE_ENUM_SERIALIZATION"] =
+ static_cast(JSON_DISABLE_ENUM_SERIALIZATION);
+
+ result["config"]["JSON_HAS_CPP_11"] =
+#ifdef JSON_HAS_CPP_11
+ true;
+#else
+ false;
+#endif
+
+ result["config"]["JSON_HAS_CPP_14"] =
+#ifdef JSON_HAS_CPP_14
+ true;
+#else
+ false;
+#endif
+
+ result["config"]["JSON_HAS_CPP_17"] =
+#ifdef JSON_HAS_CPP_17
+ true;
+#else
+ false;
+#endif
+
+ result["config"]["JSON_HAS_CPP_20"] =
+#ifdef JSON_HAS_CPP_20
+ true;
+#else
+ false;
+#endif
+
+ result["config"]["JSON_HAS_CPP_23"] =
+#ifdef JSON_HAS_CPP_23
+ true;
+#else
+ false;
+#endif
+
+ result["config"]["JSON_HAS_EXPERIMENTAL_FILESYSTEM"] =
+ static_cast(JSON_HAS_EXPERIMENTAL_FILESYSTEM);
+
+ result["config"]["JSON_HAS_FILESYSTEM"] =
+ static_cast(JSON_HAS_FILESYSTEM);
+
+ result["config"]["JSON_HAS_THREE_WAY_COMPARISON"] =
+ static_cast(JSON_HAS_THREE_WAY_COMPARISON);
+
+ result["config"]["JSON_NOEXCEPTION"] =
+#ifdef JSON_NOEXCEPTION
+ true;
+#else
+ false;
+#endif
+
+ result["config"]["JSON_NO_IO"] =
+#ifdef JSON_NO_IO
+ true;
+#else
+ false;
+#endif
+
+ result["config"]["JSON_USE_IMPLICIT_CONVERSIONS"] =
+ static_cast(JSON_USE_IMPLICIT_CONVERSIONS);
+
+ result["config"]["JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON"] =
+ static_cast(JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON);
+
+ result["config"]["NLOHMANN_JSON_ABI_STRING"] =
+ JSON_HEDLEY_STRINGIFY(NLOHMANN_JSON_ABI_STRING);
+
+ // NOLINTEND(modernize-use-bool-literals)
+
return result;
}
diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp
index beee0136c..ededc21b0 100644
--- a/single_include/nlohmann/json.hpp
+++ b/single_include/nlohmann/json.hpp
@@ -2379,7 +2379,11 @@ JSON_HEDLEY_DIAGNOSTIC_POP
#ifdef __has_include
#if __has_include()
#include
+ #elif __has_include()
+ #include
#endif
+#else
+ #include
#endif
#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
@@ -19321,9 +19325,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
{
basic_json result;
- result["copyright"] = "(C) 2013-2022 Niels Lohmann";
result["name"] = "JSON for Modern C++";
- result["url"] = "https://github.com/nlohmann/json";
result["version"]["string"] =
detail::concat(std::to_string(NLOHMANN_JSON_VERSION_MAJOR), '.',
std::to_string(NLOHMANN_JSON_VERSION_MINOR), '.',
@@ -19331,6 +19333,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
result["version"]["major"] = NLOHMANN_JSON_VERSION_MAJOR;
result["version"]["minor"] = NLOHMANN_JSON_VERSION_MINOR;
result["version"]["patch"] = NLOHMANN_JSON_VERSION_PATCH;
+ result["url"] = "https://github.com/nlohmann/json";
+ result["copyright"] = "(C) 2013-2022 Niels Lohmann";
#ifdef _WIN32
result["platform"] = "win32";
@@ -19355,12 +19359,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
std::to_string(__GNUC_PATCHLEVEL__))
}
};
-#elif defined(__HP_cc) || defined(__HP_aCC)
- result["compiler"] = "hp"
+#elif defined(__HP_aCC)
+ result["compiler"] = {{"family", "hp"}, {"version", __HP_aCC}};
+#elif defined(__HP_cc)
+ result["compiler"] = {{"family", "hp"}, {"version", __HP_cc}};
#elif defined(__IBMCPP__)
result["compiler"] = {{"family", "ilecpp"}, {"version", __IBMCPP__}};
#elif defined(_MSC_VER)
- result["compiler"] = {{"family", "msvc"}, {"version", _MSC_VER}};
+ result["compiler"] = {{"family", "msvc"}, {"version", _MSC_VER}, {"version_full", _MSC_FULL_VER}};
#elif defined(__PGI)
result["compiler"] = {{"family", "pgcpp"}, {"version", __PGI}};
#elif defined(__SUNPRO_CC)
@@ -19369,7 +19375,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}};
#endif
-
#if defined(_MSVC_LANG)
result["compiler"]["c++"] = std::to_string(_MSVC_LANG);
#elif defined(__cplusplus)
@@ -19377,6 +19382,95 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
#else
result["compiler"]["c++"] = "unknown";
#endif
+
+ // see https://en.cppreference.com/w/cpp/header/ciso646
+#ifdef _LIBCPP_VERSION
+ result["compiler"]["libc++"] = {{"family", "LLVM libc++"}, {"version", _LIBCPP_VERSION}};
+#elif __GLIBCXX__ // Note: only version 6.1 or newer define this in ciso646
+ result["compiler"]["libc++"] = {{"family", "GNU libstdc++"}, {"version", __GLIBCXX__}};
+#elif _CPPLIB_VER
+ result["compiler"]["libc++"] = {{"family", "Microsoft STL"}, {"version", _CPPLIB_VER}};
+#else
+ result["compiler"]["libc++"] = {{"family", "unknown"}, {"version", "unknown"}};
+#endif
+
+ // NOLINTBEGIN(modernize-use-bool-literals)
+
+ result["config"]["JSON_DIAGNOSTICS"] =
+ static_cast(JSON_DIAGNOSTICS); // NOLINT(modernize-use-bool-literals)
+
+ result["config"]["JSON_DISABLE_ENUM_SERIALIZATION"] =
+ static_cast(JSON_DISABLE_ENUM_SERIALIZATION);
+
+ result["config"]["JSON_HAS_CPP_11"] =
+#ifdef JSON_HAS_CPP_11
+ true;
+#else
+ false;
+#endif
+
+ result["config"]["JSON_HAS_CPP_14"] =
+#ifdef JSON_HAS_CPP_14
+ true;
+#else
+ false;
+#endif
+
+ result["config"]["JSON_HAS_CPP_17"] =
+#ifdef JSON_HAS_CPP_17
+ true;
+#else
+ false;
+#endif
+
+ result["config"]["JSON_HAS_CPP_20"] =
+#ifdef JSON_HAS_CPP_20
+ true;
+#else
+ false;
+#endif
+
+ result["config"]["JSON_HAS_CPP_23"] =
+#ifdef JSON_HAS_CPP_23
+ true;
+#else
+ false;
+#endif
+
+ result["config"]["JSON_HAS_EXPERIMENTAL_FILESYSTEM"] =
+ static_cast(JSON_HAS_EXPERIMENTAL_FILESYSTEM);
+
+ result["config"]["JSON_HAS_FILESYSTEM"] =
+ static_cast(JSON_HAS_FILESYSTEM);
+
+ result["config"]["JSON_HAS_THREE_WAY_COMPARISON"] =
+ static_cast(JSON_HAS_THREE_WAY_COMPARISON);
+
+ result["config"]["JSON_NOEXCEPTION"] =
+#ifdef JSON_NOEXCEPTION
+ true;
+#else
+ false;
+#endif
+
+ result["config"]["JSON_NO_IO"] =
+#ifdef JSON_NO_IO
+ true;
+#else
+ false;
+#endif
+
+ result["config"]["JSON_USE_IMPLICIT_CONVERSIONS"] =
+ static_cast(JSON_USE_IMPLICIT_CONVERSIONS);
+
+ result["config"]["JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON"] =
+ static_cast(JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON);
+
+ result["config"]["NLOHMANN_JSON_ABI_STRING"] =
+ JSON_HEDLEY_STRINGIFY(NLOHMANN_JSON_ABI_STRING);
+
+ // NOLINTEND(modernize-use-bool-literals)
+
return result;
}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 65b610f0e..f13bbf4c7 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -6,6 +6,8 @@ option(JSON_FastTests "Skip expensive/slow tests." OFF)
set(JSON_32bitTest AUTO CACHE STRING "Enable the 32bit unit test (ON/OFF/AUTO/ONLY).")
set(JSON_TestStandards "" CACHE STRING "The list of standards to test explicitly.")
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
+
include(test)
#############################################################################
@@ -94,6 +96,22 @@ json_test_set_test_options(test-disabled_exceptions
# raise timeout of expensive Unicode test
json_test_set_test_options(test-unicode4 TEST_PROPERTIES TIMEOUT 3000)
+#############################################################################
+# define additional macro to C++ standard version mappings
+#############################################################################
+
+json_test_add_standard_keyphrases(
+ PHRASES
+ JSON_HAS_EXPERIMENTAL_FILESYSTEM
+ JSON_HAS_FILESYSTEM
+ CXX_STANDARDS 17)
+
+json_test_add_standard_keyphrases(
+ PHRASES
+ JSON_HAS_RANGES
+ JSON_HAS_THREE_WAY_COMPARISON
+ CXX_STANDARDS 20)
+
#############################################################################
# add unit tests
#############################################################################
@@ -172,3 +190,39 @@ add_subdirectory(cmake_add_subdirectory)
add_subdirectory(cmake_fetch_content)
add_subdirectory(cmake_fetch_content2)
add_subdirectory(cmake_target_include_directories)
+
+#############################################################################
+# print JSON meta for tested C++ standard versions
+#############################################################################
+
+set(print_meta_targets)
+set(print_meta_commands)
+foreach(cxx_standard ${test_cxx_standards})
+ if(NOT compiler_supports_cpp_${cxx_standard})
+ continue()
+ endif()
+
+ set(print_meta_target print_meta_cpp${cxx_standard})
+ add_executable(${print_meta_target} EXCLUDE_FROM_ALL src/print_meta.cpp)
+ target_compile_definitions(${print_meta_target} PRIVATE JSON_TEST_PRINT_META_WITH_MAIN JSON_TEST_NAME=${print_meta_target})
+ target_compile_options(${print_meta_target} PRIVATE $<$:/EHsc;$<$:/Od>>)
+ target_link_libraries(${print_meta_target} PRIVATE ${NLOHMANN_JSON_TARGET_NAME})
+
+ # set and require C++ standard
+ set_target_properties(${print_meta_target} PROPERTIES
+ CXX_STANDARD ${cxx_standard}
+ CXX_STANDARD_REQUIRED ON
+ )
+
+ # apply standard-specific build settings
+ if(TARGET _json_test_interface__cpp_${cxx_standard})
+ target_link_libraries(${print_meta_target} PRIVATE _json_test_interface__cpp_${cxx_standard})
+ endif()
+
+ list(APPEND print_meta_targets ${print_meta_target})
+ list(APPEND print_meta_commands COMMAND ${print_meta_target})
+endforeach()
+
+add_custom_target(print_meta
+ ${print_meta_commands}
+ USES_TERMINAL)
diff --git a/cmake/download_test_data.cmake b/tests/cmake/download_test_data.cmake
similarity index 100%
rename from cmake/download_test_data.cmake
rename to tests/cmake/download_test_data.cmake
diff --git a/cmake/test.cmake b/tests/cmake/test.cmake
similarity index 83%
rename from cmake/test.cmake
rename to tests/cmake/test.cmake
index bb840c6c0..551729e79 100644
--- a/cmake/test.cmake
+++ b/tests/cmake/test.cmake
@@ -42,6 +42,37 @@ endforeach()
# test functions
#############################################################################
+#############################################################################
+# json_test_add_standard_keyphrases(
+# PHRASES ...
+# CXX_STANDARDS ...)
+#
+# Create a mapping between C++ standard versions and key phrases.
+#
+# json_test_add_test_for() will search for these key phrases and build tests
+# for associated C++ standard versions.
+#############################################################################
+
+function(json_test_add_standard_keyphrases)
+ cmake_parse_arguments(args "" ""
+ "CXX_STANDARDS;PHRASES"
+ ${ARGN})
+
+ if(NOT args_PHRASES)
+ message(FATAL_ERROR "At least one key phrase is required.")
+ endif()
+
+ if(NOT args_CXX_STANDARDS)
+ message(FATAL_ERROR "At least one C++ standard version is required.")
+ endif()
+
+ foreach(cxx_standard ${args_CXX_STANDARDS})
+ set(var _JSON_TEST_STANDARD_KEYPHRASES_CPP_${cxx_standard})
+ list(APPEND ${var} ${args_PHRASES})
+ set(${var} CACHE INTERNAL "Mapping of key phrases to C++ standard version ${cxx_standard}")
+ endforeach()
+endfunction()
+
#############################################################################
# json_test_set_test_options(
# all|
@@ -117,7 +148,18 @@ function(_json_test_add_test test_name file main cxx_standard)
message(FATAL_ERROR "Target ${test_target} has already been added.")
endif()
+ file(READ ${file} file_content)
+ string(REGEX MATCH "[\n\r \t]+#[ \t]*include[ \t]+\"print_meta.cpp\"" match_result "${file_content}")
+ if(NOT match_result)
+ message(FATAL_ERROR "Please append\n"
+ "#include \"print_meta.cpp\" // NOLINT(bugprone-suspicious-include)\n"
+ "to the end of file: ${file}")
+ endif()
+
+ # add test executable
add_executable(${test_target} ${file})
+ # add parentheses to silence clang-tidy warning
+ target_compile_definitions(${test_target} PRIVATE "JSON_TEST_NAME=(${test_target})")
target_link_libraries(${test_target} PRIVATE ${main})
# set and require C++ standard
@@ -233,8 +275,15 @@ function(json_test_add_test_for file)
# add unconditionally if C++11 (default) or forced
if(NOT ("${cxx_standard}" STREQUAL 11 OR args_FORCE))
- string(FIND "${file_content}" JSON_HAS_CPP_${cxx_standard} has_cpp_found)
- if(${has_cpp_found} EQUAL -1)
+ set(build FALSE)
+ foreach(phrase JSON_HAS_CPP_${cxx_standard} ${_JSON_TEST_STANDARD_KEYPHRASES_CPP_${cxx_standard}})
+ string(FIND "${file_content}" ${phrase} phrase_found)
+ if(NOT ${phrase_found} EQUAL -1)
+ set(build TRUE)
+ break()
+ endif()
+ endforeach()
+ if(NOT build)
continue()
endif()
endif()
diff --git a/tests/src/print_meta.cpp b/tests/src/print_meta.cpp
new file mode 100644
index 000000000..e8a14c71b
--- /dev/null
+++ b/tests/src/print_meta.cpp
@@ -0,0 +1,44 @@
+// __ _____ _____ _____
+// __| | __| | | | JSON for Modern C++ (supporting code)
+// | | |__ | | | | | | version 3.10.5
+// |_____|_____|_____|_|___| https://github.com/nlohmann/json
+//
+// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-License-Identifier: MIT
+
+#include
+
+#ifdef JSON_TEST_PRINT_META_WITH_MAIN
+ #include
+#endif
+
+#define STRINGIZE_EX(x) #x
+#define STRINGIZE(x) STRINGIZE_EX(x)
+
+void print_meta();
+
+void print_meta()
+{
+ auto meta = nlohmann::ordered_json::meta();
+ meta.erase("name");
+ meta.erase("url");
+ meta.erase("copyright");
+ meta["version"] = meta["version"]["string"];
+
+ // strip off the parentheses added to silence clang-tidy warning
+ auto strip_parens = [](const std::string & str)
+ {
+ return (str[0] == '(') ? std::string(str.data() + 1, str.size() - 2) : str;
+ };
+ std::cout << strip_parens(STRINGIZE(JSON_TEST_NAME)) << '\n';
+ std::cout << meta.dump(4) << '\n' << std::endl;
+}
+
+#ifdef JSON_TEST_PRINT_META_WITH_MAIN
+int main(int /*argc*/, char* /*argv*/[])
+{
+ print_meta();
+
+ return 0;
+}
+#endif
diff --git a/tests/src/unit-32bit.cpp b/tests/src/unit-32bit.cpp
index 82e6f33b2..c82cb3664 100644
--- a/tests/src/unit-32bit.cpp
+++ b/tests/src/unit-32bit.cpp
@@ -134,3 +134,5 @@ TEST_CASE("BJData")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-algorithms.cpp b/tests/src/unit-algorithms.cpp
index d10c14dcf..3a7886024 100644
--- a/tests/src/unit-algorithms.cpp
+++ b/tests/src/unit-algorithms.cpp
@@ -295,3 +295,5 @@ TEST_CASE("algorithms")
CHECK(j_array == json({false, true, 3, 13, 29, {{"one", 1}, {"two", 2}}, {1, 2, 3}, "baz", "foo"}));
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-allocator.cpp b/tests/src/unit-allocator.cpp
index 9e5edc4f8..51c321aa3 100644
--- a/tests/src/unit-allocator.cpp
+++ b/tests/src/unit-allocator.cpp
@@ -252,3 +252,5 @@ TEST_CASE("bad my_allocator::construct")
j["test"].push_back("should not leak");
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-alt-string.cpp b/tests/src/unit-alt-string.cpp
index 0c94d0fb9..a760c0ecd 100644
--- a/tests/src/unit-alt-string.cpp
+++ b/tests/src/unit-alt-string.cpp
@@ -322,3 +322,5 @@ TEST_CASE("alternative string type")
CHECK(j.at(alt_json::json_pointer("/foo/1")) == j["foo"][1]);
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-assert_macro.cpp b/tests/src/unit-assert_macro.cpp
index e9be6b5e2..f45e41ceb 100644
--- a/tests/src/unit-assert_macro.cpp
+++ b/tests/src/unit-assert_macro.cpp
@@ -46,3 +46,5 @@ TEST_CASE("JSON_ASSERT(x)")
DOCTEST_GCC_SUPPRESS_WARNING_POP
DOCTEST_CLANG_SUPPRESS_WARNING_POP
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-binary_formats.cpp b/tests/src/unit-binary_formats.cpp
index 896bc1bdb..8c18a79ac 100644
--- a/tests/src/unit-binary_formats.cpp
+++ b/tests/src/unit-binary_formats.cpp
@@ -209,3 +209,5 @@ TEST_CASE("Binary Formats" * doctest::skip())
CHECK((100.0 * double(ubjson_3_size) / double(json_size)) == Approx(89.450));
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-bjdata.cpp b/tests/src/unit-bjdata.cpp
index c245e87e9..52eadf5cc 100644
--- a/tests/src/unit-bjdata.cpp
+++ b/tests/src/unit-bjdata.cpp
@@ -3547,3 +3547,5 @@ TEST_CASE("BJData roundtrips" * doctest::skip())
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-bson.cpp b/tests/src/unit-bson.cpp
index 05fe8d3e8..3c876049e 100644
--- a/tests/src/unit-bson.cpp
+++ b/tests/src/unit-bson.cpp
@@ -1296,3 +1296,5 @@ TEST_CASE("BSON roundtrips" * doctest::skip())
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-byte_container_with_subtype.cpp b/tests/src/unit-byte_container_with_subtype.cpp
index c651273fe..6dd66070f 100644
--- a/tests/src/unit-byte_container_with_subtype.cpp
+++ b/tests/src/unit-byte_container_with_subtype.cpp
@@ -75,3 +75,5 @@ TEST_CASE("byte_container_with_subtype")
CHECK(container2 == container4);
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-capacity.cpp b/tests/src/unit-capacity.cpp
index 858e111ad..59de2e25c 100644
--- a/tests/src/unit-capacity.cpp
+++ b/tests/src/unit-capacity.cpp
@@ -541,3 +541,5 @@ TEST_CASE("capacity")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-cbor.cpp b/tests/src/unit-cbor.cpp
index 78bdeb2b9..66d013fe9 100644
--- a/tests/src/unit-cbor.cpp
+++ b/tests/src/unit-cbor.cpp
@@ -2665,3 +2665,5 @@ TEST_CASE("Tagged values")
CHECK(!jb["binary"].get_binary().has_subtype());
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-class_const_iterator.cpp b/tests/src/unit-class_const_iterator.cpp
index 8e0bc823e..a468d18b0 100644
--- a/tests/src/unit-class_const_iterator.cpp
+++ b/tests/src/unit-class_const_iterator.cpp
@@ -391,3 +391,5 @@ TEST_CASE("const_iterator class")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-class_iterator.cpp b/tests/src/unit-class_iterator.cpp
index 7568d927d..711a21366 100644
--- a/tests/src/unit-class_iterator.cpp
+++ b/tests/src/unit-class_iterator.cpp
@@ -466,3 +466,5 @@ TEST_CASE("iterator class")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-class_lexer.cpp b/tests/src/unit-class_lexer.cpp
index 9991b355e..be77916ca 100644
--- a/tests/src/unit-class_lexer.cpp
+++ b/tests/src/unit-class_lexer.cpp
@@ -224,3 +224,5 @@ TEST_CASE("lexer class")
CHECK((scan_string("/**//**//**/", true) == json::lexer::token_type::end_of_input));
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-class_parser.cpp b/tests/src/unit-class_parser.cpp
index 86dd85a7f..8115a5cf7 100644
--- a/tests/src/unit-class_parser.cpp
+++ b/tests/src/unit-class_parser.cpp
@@ -1689,3 +1689,5 @@ TEST_CASE("parser class")
CHECK_THROWS_WITH_AS(_ = json::parse("/*", nullptr, true, true), "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid comment; missing closing '*/'; last read: '/*'", json::parse_error);
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-comparison.cpp b/tests/src/unit-comparison.cpp
index f713c980a..a97c50a87 100644
--- a/tests/src/unit-comparison.cpp
+++ b/tests/src/unit-comparison.cpp
@@ -593,3 +593,5 @@ TEST_CASE("lexicographical comparison operators")
}
#endif
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-concepts.cpp b/tests/src/unit-concepts.cpp
index c179b0c3c..206c2dd0f 100644
--- a/tests/src/unit-concepts.cpp
+++ b/tests/src/unit-concepts.cpp
@@ -148,3 +148,5 @@ TEST_CASE("concepts")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-constructor1.cpp b/tests/src/unit-constructor1.cpp
index f294e5cd6..b12d2a169 100644
--- a/tests/src/unit-constructor1.cpp
+++ b/tests/src/unit-constructor1.cpp
@@ -1569,3 +1569,5 @@ TEST_CASE("constructors")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-constructor2.cpp b/tests/src/unit-constructor2.cpp
index b1b5a6ed4..411c871c6 100644
--- a/tests/src/unit-constructor2.cpp
+++ b/tests/src/unit-constructor2.cpp
@@ -184,3 +184,5 @@ TEST_CASE("other constructors and destructor")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-convenience.cpp b/tests/src/unit-convenience.cpp
index fcb772320..948f9aa71 100644
--- a/tests/src/unit-convenience.cpp
+++ b/tests/src/unit-convenience.cpp
@@ -203,3 +203,5 @@ TEST_CASE("convenience functions")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-conversions.cpp b/tests/src/unit-conversions.cpp
index d86b614c4..f5312ed00 100644
--- a/tests/src/unit-conversions.cpp
+++ b/tests/src/unit-conversions.cpp
@@ -1570,3 +1570,5 @@ TEST_CASE("JSON to enum mapping")
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-deserialization.cpp b/tests/src/unit-deserialization.cpp
index 3616f35c5..5dc1be7c8 100644
--- a/tests/src/unit-deserialization.cpp
+++ b/tests/src/unit-deserialization.cpp
@@ -1187,3 +1187,5 @@ TEST_CASE_TEMPLATE("deserialization of different character types (UTF-32)", T,
CHECK(json::sax_parse(v, &l));
CHECK(l.events.size() == 1);
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-diagnostics.cpp b/tests/src/unit-diagnostics.cpp
index a1aff57af..121d84ea8 100644
--- a/tests/src/unit-diagnostics.cpp
+++ b/tests/src/unit-diagnostics.cpp
@@ -244,3 +244,5 @@ TEST_CASE("Regression tests for extended diagnostics")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-disabled_exceptions.cpp b/tests/src/unit-disabled_exceptions.cpp
index 6a7d5000d..eff5099fe 100644
--- a/tests/src/unit-disabled_exceptions.cpp
+++ b/tests/src/unit-disabled_exceptions.cpp
@@ -50,3 +50,5 @@ TEST_CASE("Tests with disabled exceptions")
}
DOCTEST_GCC_SUPPRESS_WARNING_POP
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-element_access1.cpp b/tests/src/unit-element_access1.cpp
index f28f2f9f2..e09c64f5b 100644
--- a/tests/src/unit-element_access1.cpp
+++ b/tests/src/unit-element_access1.cpp
@@ -879,3 +879,5 @@ TEST_CASE("element access 1")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-element_access2.cpp b/tests/src/unit-element_access2.cpp
index 5f28e5a2c..db2c5f25f 100644
--- a/tests/src/unit-element_access2.cpp
+++ b/tests/src/unit-element_access2.cpp
@@ -1488,3 +1488,5 @@ TEST_CASE_TEMPLATE("element access 2 (throwing tests)", Json, nlohmann::json, nl
}
}
#endif
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-hash.cpp b/tests/src/unit-hash.cpp
index 1ed21bd39..bbbbdc14c 100644
--- a/tests/src/unit-hash.cpp
+++ b/tests/src/unit-hash.cpp
@@ -111,3 +111,5 @@ TEST_CASE("hash")
CHECK(hashes.size() == 21);
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-inspection.cpp b/tests/src/unit-inspection.cpp
index c5ea684d0..7277d5f3e 100644
--- a/tests/src/unit-inspection.cpp
+++ b/tests/src/unit-inspection.cpp
@@ -457,3 +457,5 @@ TEST_CASE("object inspection")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-items.cpp b/tests/src/unit-items.cpp
index 55d9edd39..22708061d 100644
--- a/tests/src/unit-items.cpp
+++ b/tests/src/unit-items.cpp
@@ -1431,3 +1431,5 @@ TEST_CASE("items()")
DOCTEST_GCC_SUPPRESS_WARNING_POP
DOCTEST_CLANG_SUPPRESS_WARNING_POP
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-iterators1.cpp b/tests/src/unit-iterators1.cpp
index 14bbdf844..494aac832 100644
--- a/tests/src/unit-iterators1.cpp
+++ b/tests/src/unit-iterators1.cpp
@@ -1628,3 +1628,5 @@ TEST_CASE("iterators 1")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-iterators2.cpp b/tests/src/unit-iterators2.cpp
index 57326a289..bc53f6cf3 100644
--- a/tests/src/unit-iterators2.cpp
+++ b/tests/src/unit-iterators2.cpp
@@ -970,3 +970,5 @@ TEST_CASE("iterators 2")
}
#endif
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-json_patch.cpp b/tests/src/unit-json_patch.cpp
index 3be0f8ecf..df99e2744 100644
--- a/tests/src/unit-json_patch.cpp
+++ b/tests/src/unit-json_patch.cpp
@@ -1319,3 +1319,5 @@ TEST_CASE("JSON patch")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-json_pointer.cpp b/tests/src/unit-json_pointer.cpp
index f6e2b00c0..1db45cb28 100644
--- a/tests/src/unit-json_pointer.cpp
+++ b/tests/src/unit-json_pointer.cpp
@@ -759,3 +759,5 @@ TEST_CASE("JSON pointers")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-large_json.cpp b/tests/src/unit-large_json.cpp
index 69f47df64..e59ac6502 100644
--- a/tests/src/unit-large_json.cpp
+++ b/tests/src/unit-large_json.cpp
@@ -27,3 +27,5 @@ TEST_CASE("tests on very large JSONs")
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-merge_patch.cpp b/tests/src/unit-merge_patch.cpp
index 5098d1278..7622c0460 100644
--- a/tests/src/unit-merge_patch.cpp
+++ b/tests/src/unit-merge_patch.cpp
@@ -242,3 +242,5 @@ TEST_CASE("JSON Merge Patch")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-meta.cpp b/tests/src/unit-meta.cpp
index ad3a841c6..8d78c00c9 100644
--- a/tests/src/unit-meta.cpp
+++ b/tests/src/unit-meta.cpp
@@ -28,9 +28,20 @@ TEST_CASE("version information")
{"patch", 1}
}));
- CHECK(j.find("platform") != j.end());
- CHECK(j.at("compiler").find("family") != j.at("compiler").end());
- CHECK(j.at("compiler").find("version") != j.at("compiler").end());
- CHECK(j.at("compiler").find("c++") != j.at("compiler").end());
+ CHECK(j.contains("platform"));
+ CHECK(j.contains("compiler"));
+ CHECK(j.contains("config"));
+
+ const auto& j_cxx = j["compiler"];
+ CHECK(j_cxx.contains("family"));
+ CHECK(j_cxx.contains("version"));
+ CHECK(j_cxx.contains("c++"));
+ CHECK(j_cxx.contains("libc++"));
+
+ const auto& j_lib = j_cxx["libc++"];
+ CHECK(j_lib.contains("family"));
+ CHECK(j_lib.contains("version"));
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-modifiers.cpp b/tests/src/unit-modifiers.cpp
index 8b06f1809..6c74ef817 100644
--- a/tests/src/unit-modifiers.cpp
+++ b/tests/src/unit-modifiers.cpp
@@ -951,3 +951,5 @@ TEST_CASE("modifiers")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-msgpack.cpp b/tests/src/unit-msgpack.cpp
index d0e5ff3d5..61d01f903 100644
--- a/tests/src/unit-msgpack.cpp
+++ b/tests/src/unit-msgpack.cpp
@@ -1835,3 +1835,5 @@ TEST_CASE("MessagePack roundtrips" * doctest::skip())
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-noexcept.cpp b/tests/src/unit-noexcept.cpp
index 89a7db7b0..d2ad27061 100644
--- a/tests/src/unit-noexcept.cpp
+++ b/tests/src/unit-noexcept.cpp
@@ -34,20 +34,18 @@ void to_json(json& /*unused*/, pod_bis /*unused*/) {}
void from_json(const json& /*unused*/, pod /*unused*/) noexcept {}
void from_json(const json& /*unused*/, pod_bis /*unused*/) {}
-json* j = nullptr;
-
static_assert(noexcept(json{}), "");
-static_assert(noexcept(nlohmann::to_json(*j, 2)), "");
-static_assert(noexcept(nlohmann::to_json(*j, 2.5)), "");
-static_assert(noexcept(nlohmann::to_json(*j, true)), "");
-static_assert(noexcept(nlohmann::to_json(*j, test{})), "");
-static_assert(noexcept(nlohmann::to_json(*j, pod{})), "");
-static_assert(!noexcept(nlohmann::to_json(*j, pod_bis{})), "");
+static_assert(noexcept(nlohmann::to_json(std::declval(), 2)), "");
+static_assert(noexcept(nlohmann::to_json(std::declval(), 2.5)), "");
+static_assert(noexcept(nlohmann::to_json(std::declval(), true)), "");
+static_assert(noexcept(nlohmann::to_json(std::declval(), test{})), "");
+static_assert(noexcept(nlohmann::to_json(std::declval(), pod{})), "");
+static_assert(!noexcept(nlohmann::to_json(std::declval(), pod_bis{})), "");
static_assert(noexcept(json(2)), "");
static_assert(noexcept(json(test{})), "");
static_assert(noexcept(json(pod{})), "");
-static_assert(noexcept(j->get()), "");
-static_assert(!noexcept(j->get()), "");
+static_assert(noexcept(std::declval().get()), "");
+static_assert(!noexcept(std::declval().get()), "");
static_assert(noexcept(json(pod{})), "");
} // namespace
@@ -70,7 +68,6 @@ TEST_CASE("runtime checks")
SECTION("silence -Wunneeded-internal-declaration errors")
{
- j = nullptr;
json j2;
to_json(j2, pod());
to_json(j2, pod_bis());
@@ -80,3 +77,5 @@ TEST_CASE("runtime checks")
}
DOCTEST_GCC_SUPPRESS_WARNING_POP
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-ordered_json.cpp b/tests/src/unit-ordered_json.cpp
index 3ce0aa155..a73949741 100644
--- a/tests/src/unit-ordered_json.cpp
+++ b/tests/src/unit-ordered_json.cpp
@@ -70,3 +70,5 @@ TEST_CASE("ordered_json")
CHECK(oj1.size() == 4);
CHECK(oj1.dump() == "{\"c\":1,\"b\":2,\"a\":3,\"d\":42}");
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-ordered_map.cpp b/tests/src/unit-ordered_map.cpp
index d907263b4..b265f0361 100644
--- a/tests/src/unit-ordered_map.cpp
+++ b/tests/src/unit-ordered_map.cpp
@@ -309,3 +309,5 @@ TEST_CASE("ordered_map")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-pointer_access.cpp b/tests/src/unit-pointer_access.cpp
index b48a4297c..9f9b86eec 100644
--- a/tests/src/unit-pointer_access.cpp
+++ b/tests/src/unit-pointer_access.cpp
@@ -477,3 +477,5 @@ TEST_CASE("pointer access")
CHECK(value.get_ptr() != nullptr);
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-readme.cpp b/tests/src/unit-readme.cpp
index 6d296f02f..fc7e643a4 100644
--- a/tests/src/unit-readme.cpp
+++ b/tests/src/unit-readme.cpp
@@ -303,3 +303,5 @@ TEST_CASE("README" * doctest::skip())
}
DOCTEST_MSVC_SUPPRESS_WARNING_POP
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-reference_access.cpp b/tests/src/unit-reference_access.cpp
index abe8bd1f5..7eb7acf9b 100644
--- a/tests/src/unit-reference_access.cpp
+++ b/tests/src/unit-reference_access.cpp
@@ -245,3 +245,5 @@ TEST_CASE("reference access")
CHECK_NOTHROW(value.get_ref());
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-regression1.cpp b/tests/src/unit-regression1.cpp
index 45c4bd620..ce500ca4d 100644
--- a/tests/src/unit-regression1.cpp
+++ b/tests/src/unit-regression1.cpp
@@ -1511,3 +1511,5 @@ template class number_integer {};
template class number_unsigned {};
template class number_float {};
#endif
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-regression2.cpp b/tests/src/unit-regression2.cpp
index 73c8f3906..d99876038 100644
--- a/tests/src/unit-regression2.cpp
+++ b/tests/src/unit-regression2.cpp
@@ -926,3 +926,5 @@ TEST_CASE("regression tests 2")
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-serialization.cpp b/tests/src/unit-serialization.cpp
index 50dc58b4c..418a6038a 100644
--- a/tests/src/unit-serialization.cpp
+++ b/tests/src/unit-serialization.cpp
@@ -295,3 +295,5 @@ TEST_CASE("dump with binary values")
"]");
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-testsuites.cpp b/tests/src/unit-testsuites.cpp
index 268a48327..6c5eec77f 100644
--- a/tests/src/unit-testsuites.cpp
+++ b/tests/src/unit-testsuites.cpp
@@ -1389,3 +1389,5 @@ TEST_CASE("Big List of Naughty Strings")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-to_chars.cpp b/tests/src/unit-to_chars.cpp
index 44d4f3801..6dcb363d7 100644
--- a/tests/src/unit-to_chars.cpp
+++ b/tests/src/unit-to_chars.cpp
@@ -514,3 +514,5 @@ TEST_CASE("formatting")
check_integer(1000000000000000000LL, "1000000000000000000");
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-ubjson.cpp b/tests/src/unit-ubjson.cpp
index 5086149ce..6f7773703 100644
--- a/tests/src/unit-ubjson.cpp
+++ b/tests/src/unit-ubjson.cpp
@@ -2515,3 +2515,5 @@ TEST_CASE("UBJSON roundtrips" * doctest::skip())
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-udl.cpp b/tests/src/unit-udl.cpp
index 934744364..238bdbc5d 100644
--- a/tests/src/unit-udl.cpp
+++ b/tests/src/unit-udl.cpp
@@ -55,3 +55,5 @@ TEST_CASE("user-defined string literals")
}
#endif
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-udt.cpp b/tests/src/unit-udt.cpp
index 681536f95..e7520b456 100644
--- a/tests/src/unit-udt.cpp
+++ b/tests/src/unit-udt.cpp
@@ -862,3 +862,5 @@ TEST_CASE("compatible array type, without iterator type alias")
}
DOCTEST_GCC_SUPPRESS_WARNING_POP
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-udt_macro.cpp b/tests/src/unit-udt_macro.cpp
index eed81cdfa..d2b61303e 100644
--- a/tests/src/unit-udt_macro.cpp
+++ b/tests/src/unit-udt_macro.cpp
@@ -412,3 +412,5 @@ TEST_CASE_TEMPLATE("Serialization/deserialization of classes with 26 public/priv
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-unicode1.cpp b/tests/src/unit-unicode1.cpp
index 03c5b8006..9eb59eab5 100644
--- a/tests/src/unit-unicode1.cpp
+++ b/tests/src/unit-unicode1.cpp
@@ -618,3 +618,5 @@ TEST_CASE("Markus Kuhn's UTF-8 decoder capability and stress test")
}
}
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-unicode2.cpp b/tests/src/unit-unicode2.cpp
index b91d0be86..7025898c1 100644
--- a/tests/src/unit-unicode2.cpp
+++ b/tests/src/unit-unicode2.cpp
@@ -608,3 +608,5 @@ TEST_CASE("Unicode (2/5)" * doctest::skip())
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-unicode3.cpp b/tests/src/unit-unicode3.cpp
index d5740e3e0..dd3fb6465 100644
--- a/tests/src/unit-unicode3.cpp
+++ b/tests/src/unit-unicode3.cpp
@@ -322,3 +322,5 @@ TEST_CASE("Unicode (3/5)" * doctest::skip())
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-unicode4.cpp b/tests/src/unit-unicode4.cpp
index 0a7a58bc3..7f14114f1 100644
--- a/tests/src/unit-unicode4.cpp
+++ b/tests/src/unit-unicode4.cpp
@@ -322,3 +322,5 @@ TEST_CASE("Unicode (4/5)" * doctest::skip())
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-unicode5.cpp b/tests/src/unit-unicode5.cpp
index 2360dbe36..d788974eb 100644
--- a/tests/src/unit-unicode5.cpp
+++ b/tests/src/unit-unicode5.cpp
@@ -322,3 +322,5 @@ TEST_CASE("Unicode (5/5)" * doctest::skip())
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-user_defined_input.cpp b/tests/src/unit-user_defined_input.cpp
index a3095a8d9..22ba09b34 100644
--- a/tests/src/unit-user_defined_input.cpp
+++ b/tests/src/unit-user_defined_input.cpp
@@ -128,3 +128,5 @@ TEST_CASE("Custom iterator")
}
} // namespace
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-windows_h.cpp b/tests/src/unit-windows_h.cpp
index 5fa641091..5dd852f9a 100644
--- a/tests/src/unit-windows_h.cpp
+++ b/tests/src/unit-windows_h.cpp
@@ -19,3 +19,5 @@ TEST_CASE("include windows.h")
{
CHECK(true);
}
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit-wstring.cpp b/tests/src/unit-wstring.cpp
index b8ed08db8..01d6f5a24 100644
--- a/tests/src/unit-wstring.cpp
+++ b/tests/src/unit-wstring.cpp
@@ -97,3 +97,5 @@ TEST_CASE("wide strings")
}
}
#endif
+
+#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)
diff --git a/tests/src/unit.cpp b/tests/src/unit.cpp
index 8074687a5..d598d43c6 100644
--- a/tests/src/unit.cpp
+++ b/tests/src/unit.cpp
@@ -6,5 +6,17 @@
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
// SPDX-License-Identifier: MIT
-#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
+#define DOCTEST_CONFIG_IMPLEMENT
#include "doctest_compatibility.h"
+
+// defined in print_meta.cpp which is automatically appended to each unit test
+extern void print_meta();
+
+DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4007)
+int main(int argc, char* argv[])
+{
+ print_meta();
+
+ return doctest::Context(argc, argv).run();
+}
+DOCTEST_MSVC_SUPPRESS_WARNING_POP