This commit is contained in:
Florian Albrechtskirchinger 2022-08-05 18:57:24 +02:00 committed by GitHub
commit 1217a2ba48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
73 changed files with 683 additions and 130 deletions

View File

@ -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

View File

@ -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

View File

@ -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 <https://www.viva64.com/en/pvs-studio/>.
###############################################################################
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 <https://fbinfer.com> 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"
)

View File

@ -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,

View File

@ -50,7 +50,11 @@
#ifdef __has_include
#if __has_include(<version>)
#include <version>
#elif __has_include(<ciso646>)
#include <ciso646>
#endif
#else
#include <ciso646>
#endif
#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)

View File

@ -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<bool>(JSON_DIAGNOSTICS); // NOLINT(modernize-use-bool-literals)
result["config"]["JSON_DISABLE_ENUM_SERIALIZATION"] =
static_cast<bool>(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<bool>(JSON_HAS_EXPERIMENTAL_FILESYSTEM);
result["config"]["JSON_HAS_FILESYSTEM"] =
static_cast<bool>(JSON_HAS_FILESYSTEM);
result["config"]["JSON_HAS_THREE_WAY_COMPARISON"] =
static_cast<bool>(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<bool>(JSON_USE_IMPLICIT_CONVERSIONS);
result["config"]["JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON"] =
static_cast<bool>(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;
}

View File

@ -2379,7 +2379,11 @@ JSON_HEDLEY_DIAGNOSTIC_POP
#ifdef __has_include
#if __has_include(<version>)
#include <version>
#elif __has_include(<ciso646>)
#include <ciso646>
#endif
#else
#include <ciso646>
#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<bool>(JSON_DIAGNOSTICS); // NOLINT(modernize-use-bool-literals)
result["config"]["JSON_DISABLE_ENUM_SERIALIZATION"] =
static_cast<bool>(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<bool>(JSON_HAS_EXPERIMENTAL_FILESYSTEM);
result["config"]["JSON_HAS_FILESYSTEM"] =
static_cast<bool>(JSON_HAS_FILESYSTEM);
result["config"]["JSON_HAS_THREE_WAY_COMPARISON"] =
static_cast<bool>(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<bool>(JSON_USE_IMPLICIT_CONVERSIONS);
result["config"]["JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON"] =
static_cast<bool>(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;
}

View File

@ -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 $<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/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)

View File

@ -42,6 +42,37 @@ endforeach()
# test functions
#############################################################################
#############################################################################
# json_test_add_standard_keyphrases(
# PHRASES <args>...
# CXX_STANDARDS <args>...)
#
# 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|<tests>
@ -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()

44
tests/src/print_meta.cpp Normal file
View File

@ -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 <https://nlohmann.me>
// SPDX-License-Identifier: MIT
#include <iostream>
#ifdef JSON_TEST_PRINT_META_WITH_MAIN
#include <nlohmann/json.hpp>
#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

View File

@ -134,3 +134,5 @@ TEST_CASE("BJData")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -3547,3 +3547,5 @@ TEST_CASE("BJData roundtrips" * doctest::skip())
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -1296,3 +1296,5 @@ TEST_CASE("BSON roundtrips" * doctest::skip())
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -75,3 +75,5 @@ TEST_CASE("byte_container_with_subtype")
CHECK(container2 == container4);
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -541,3 +541,5 @@ TEST_CASE("capacity")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -2665,3 +2665,5 @@ TEST_CASE("Tagged values")
CHECK(!jb["binary"].get_binary().has_subtype());
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -391,3 +391,5 @@ TEST_CASE("const_iterator class")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -466,3 +466,5 @@ TEST_CASE("iterator class")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -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)

View File

@ -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: '/*<U+0000>'", json::parse_error);
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -593,3 +593,5 @@ TEST_CASE("lexicographical comparison operators")
}
#endif
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -148,3 +148,5 @@ TEST_CASE("concepts")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -1569,3 +1569,5 @@ TEST_CASE("constructors")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -184,3 +184,5 @@ TEST_CASE("other constructors and destructor")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -203,3 +203,5 @@ TEST_CASE("convenience functions")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -1570,3 +1570,5 @@ TEST_CASE("JSON to enum mapping")
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -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)

View File

@ -244,3 +244,5 @@ TEST_CASE("Regression tests for extended diagnostics")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -50,3 +50,5 @@ TEST_CASE("Tests with disabled exceptions")
}
DOCTEST_GCC_SUPPRESS_WARNING_POP
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -879,3 +879,5 @@ TEST_CASE("element access 1")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -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)

View File

@ -111,3 +111,5 @@ TEST_CASE("hash<nlohmann::ordered_json>")
CHECK(hashes.size() == 21);
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -457,3 +457,5 @@ TEST_CASE("object inspection")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -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)

View File

@ -1628,3 +1628,5 @@ TEST_CASE("iterators 1")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -970,3 +970,5 @@ TEST_CASE("iterators 2")
}
#endif
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -1319,3 +1319,5 @@ TEST_CASE("JSON patch")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -759,3 +759,5 @@ TEST_CASE("JSON pointers")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -27,3 +27,5 @@ TEST_CASE("tests on very large JSONs")
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -242,3 +242,5 @@ TEST_CASE("JSON Merge Patch")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -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)

View File

@ -951,3 +951,5 @@ TEST_CASE("modifiers")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -1835,3 +1835,5 @@ TEST_CASE("MessagePack roundtrips" * doctest::skip())
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -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<json&>(), 2)), "");
static_assert(noexcept(nlohmann::to_json(std::declval<json&>(), 2.5)), "");
static_assert(noexcept(nlohmann::to_json(std::declval<json&>(), true)), "");
static_assert(noexcept(nlohmann::to_json(std::declval<json&>(), test{})), "");
static_assert(noexcept(nlohmann::to_json(std::declval<json&>(), pod{})), "");
static_assert(!noexcept(nlohmann::to_json(std::declval<json&>(), pod_bis{})), "");
static_assert(noexcept(json(2)), "");
static_assert(noexcept(json(test{})), "");
static_assert(noexcept(json(pod{})), "");
static_assert(noexcept(j->get<pod>()), "");
static_assert(!noexcept(j->get<pod_bis>()), "");
static_assert(noexcept(std::declval<json&>().get<pod>()), "");
static_assert(!noexcept(std::declval<json&>().get<pod_bis>()), "");
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)

View File

@ -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)

View File

@ -309,3 +309,5 @@ TEST_CASE("ordered_map")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -477,3 +477,5 @@ TEST_CASE("pointer access")
CHECK(value.get_ptr<const json::binary_t*>() != nullptr);
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -303,3 +303,5 @@ TEST_CASE("README" * doctest::skip())
}
DOCTEST_MSVC_SUPPRESS_WARNING_POP
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -245,3 +245,5 @@ TEST_CASE("reference access")
CHECK_NOTHROW(value.get_ref<json::number_float_t&>());
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -1511,3 +1511,5 @@ template <typename T> class number_integer {};
template <typename T> class number_unsigned {};
template <typename T> class number_float {};
#endif
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -926,3 +926,5 @@ TEST_CASE("regression tests 2")
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -295,3 +295,5 @@ TEST_CASE("dump with binary values")
"]");
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -1389,3 +1389,5 @@ TEST_CASE("Big List of Naughty Strings")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -514,3 +514,5 @@ TEST_CASE("formatting")
check_integer(1000000000000000000LL, "1000000000000000000");
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -2515,3 +2515,5 @@ TEST_CASE("UBJSON roundtrips" * doctest::skip())
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -55,3 +55,5 @@ TEST_CASE("user-defined string literals")
}
#endif
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -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)

View File

@ -412,3 +412,5 @@ TEST_CASE_TEMPLATE("Serialization/deserialization of classes with 26 public/priv
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -618,3 +618,5 @@ TEST_CASE("Markus Kuhn's UTF-8 decoder capability and stress test")
}
}
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -608,3 +608,5 @@ TEST_CASE("Unicode (2/5)" * doctest::skip())
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -322,3 +322,5 @@ TEST_CASE("Unicode (3/5)" * doctest::skip())
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -322,3 +322,5 @@ TEST_CASE("Unicode (4/5)" * doctest::skip())
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -322,3 +322,5 @@ TEST_CASE("Unicode (5/5)" * doctest::skip())
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -128,3 +128,5 @@ TEST_CASE("Custom iterator")
}
} // namespace
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -19,3 +19,5 @@ TEST_CASE("include windows.h")
{
CHECK(true);
}
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -97,3 +97,5 @@ TEST_CASE("wide strings")
}
}
#endif
#include "print_meta.cpp" // NOLINT(bugprone-suspicious-include)

View File

@ -6,5 +6,17 @@
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
// 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