Skip to content

Commit

Permalink
Add tests when char_t is disabled on C++20.
Browse files Browse the repository at this point in the history
  • Loading branch information
sheredom committed Oct 26, 2024
1 parent 8937f18 commit 76b2f17
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,8 @@ jobs:
working-directory: ${{github.workspace}}/build
shell: bash
run: if [ "${{ matrix.os }}" == "windows-latest" ]; then cd ${{ matrix.type }}; fi; ./utf8_test_cpp20

- name: Test c++20 no char_t
working-directory: ${{github.workspace}}/build
shell: bash
run: if [ "${{ matrix.os }}" == "windows-latest" ]; then cd ${{ matrix.type }}; fi; ./utf8_test_cpp20_no_char_t
20 changes: 19 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#
# For more information, please refer to <http://unlicense.org/>

project(utf8)
cmake_minimum_required(VERSION 2.8.12)
project(utf8)

set(UTF8_USE_SANITIZER "" CACHE STRING "Set which Clang Sanitizer to use")

Expand Down Expand Up @@ -95,6 +95,24 @@ add_executable(utf8_test_cpp20 test.cpp)
add_sanitizer(utf8_test_cpp20)
set_target_properties(utf8_test_cpp20 PROPERTIES CXX_STANDARD 20)

add_executable(utf8_test_cpp20_no_char_t test.cpp)
add_sanitizer(utf8_test_cpp20_no_char_t)
set_target_properties(utf8_test_cpp20_no_char_t PROPERTIES CXX_STANDARD 20)

if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(utf8_test_cpp20_no_char_t PUBLIC "-fno-char8_t")
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
if("${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC")
target_compile_options(utf8_test_cpp20_no_char_t PUBLIC "/Zc:char8_t-")
else()
target_compile_options(utf8_test_cpp20_no_char_t PUBLIC "-fno-char8_t")
endif()
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
target_compile_options(utf8_test_cpp20_no_char_t PUBLIC "/Zc:char8_t-")
else()
message(WARNING "Unknown compiler '${CMAKE_C_COMPILER_ID}'!")
endif()

if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
set_source_files_properties(test.c test.cpp PROPERTIES
COMPILE_FLAGS "-Wall -Wextra -Werror"
Expand Down

0 comments on commit 76b2f17

Please sign in to comment.