Skip to content

Commit

Permalink
Fix issue of ci_test_compilers_clang (10)
Browse files Browse the repository at this point in the history
  • Loading branch information
barcode committed Jan 15, 2023
1 parent 19d8667 commit eac3dbd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ jobs:
- uses: actions/checkout@v3
- name: Get latest CMake and ninja
uses: lukka/get-cmake@latest
- name: Set env FORCE_STDCPPFS_FLAG for clang 10
run: echo "JSON_FORCED_GLOBAL_COMPILE_OPTIONS=-DJSON_HAS_FILESYSTEM=0;-DJSON_HAS_EXPERIMENTAL_FILESYSTEM=0" >> "$GITHUB_ENV"
if: ${{ matrix.compiler == '10' }}
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
Expand Down
9 changes: 9 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ 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.")

# using an env var, since this will also affect targets executing cmake (such as "ci_test_compiler_default")
set(JSON_FORCED_GLOBAL_COMPILE_OPTIONS $ENV{JSON_FORCED_GLOBAL_COMPILE_OPTIONS})
if (NOT "" STREQUAL "$ENV{JSON_FORCED_GLOBAL_COMPILE_OPTIONS}")
add_compile_options($ENV{JSON_FORCED_GLOBAL_COMPILE_OPTIONS})
endif()
if (NOT "" STREQUAL "$ENV{JSON_FORCED_GLOBAL_LINK_OPTIONS}")
add_link_options($ENV{JSON_FORCED_GLOBAL_LINK_OPTIONS})
endif()

include(test)

#############################################################################
Expand Down
6 changes: 5 additions & 1 deletion tests/src/unit-regression2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ using ordered_json = nlohmann::ordered_json;
#endif

#ifdef JSON_HAS_CPP_20
#include <span>
#if __has_include(<span>)
#include <span>
#endif
#endif

// NLOHMANN_JSON_SERIALIZE_ENUM uses a static std::pair
Expand Down Expand Up @@ -664,13 +666,15 @@ TEST_CASE("regression tests 2")
}

#ifdef JSON_HAS_CPP_20
#if __has_include(<span>)
SECTION("issue #2546 - parsing containers of std::byte")
{
const char DATA[] = R"("Hello, world!")"; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
const auto s = std::as_bytes(std::span(DATA));
const json j = json::parse(s);
CHECK(j.dump() == "\"Hello, world!\"");
}
#endif
#endif

SECTION("issue #2574 - Deserialization to std::array, std::pair, and std::tuple with non-default constructable types fails")
Expand Down

0 comments on commit eac3dbd

Please sign in to comment.