Skip to content

Commit

Permalink
add cmake ctest in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdcvlsc committed May 30, 2024
1 parent 0ffa9dd commit e8bed57
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 25 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ctests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: ctests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build-others:
name: ${{ matrix.platform.name }}-C++${{matrix.config.cxx_version}}
runs-on: ${{ matrix.platform.os }}

strategy:
fail-fast: false
matrix:
platform:
- { name: Windows VS2019, os: windows-2019}
- { name: Windows VS2022, os: windows-2022}
- { name: Windows Clang, os: windows-2022, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++}
- { name: Windows GCC, os: windows-2022, flags: -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++}
- { name: Linux Clang, os: ubuntu-latest, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
- { name: Linux, os: ubuntu-latest}
- { name: MacOS XCode, os: macos-latest}
config:
- { cxx_version: 20 }
- { cxx_version: 23 }

steps:
- uses: actions/checkout@v3

- name: System Info
run: cmake -S tests -B tests ${{matrix.platform.flags}} -DCMAKE_CXX_STANDARD=${{matrix.config.cxx_version}}

- name: Build
run: cmake --build tests --config Debug -j2

- name: Tests
run: ctest --test-dir tests
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
![tests](https://github.com/mrdcvlsc/extended-precision-integers/actions/workflows/tests.yml/badge.svg)
![ctests](https://github.com/mrdcvlsc/extended-precision-integers/actions/workflows/ctests.yml/badge.svg)

This is a C++ header-only library that offers extended precision data types, which are number types with **fixed sizes** capable of holding larger values than traditional **Plain Old Data** types (PODs) like `int`, `uint8_t`, `unsigned long`, etc.

Expand Down
43 changes: 18 additions & 25 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.16)

project(extended_precision_integers VERSION 1.0.0)
file(GLOB SOURCES "*.cpp")

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_VERBOSE_MAKEFILE OFF)
set(CMAKE_CXX_STANDARD_REQUIRED True)

add_executable("addition" "addition.cpp")
add_executable("bitwise-and" "bitwise-and.cpp")
add_executable("bitwise-not" "bitwise-not.cpp")
add_executable("bitwise-or" "bitwise-or.cpp")
add_executable("bitwise-xor" "bitwise-xor.cpp")
add_executable("boolean" "boolean.cpp")
add_executable("constructor-initializer-list" "constructor-initializer-list.cpp")
add_executable("constructor-integral" "constructor-integral.cpp")
add_executable("constructor-string-view" "constructor-string-view.cpp")
add_executable("decrement" "decrement.cpp")
add_executable("division" "division.cpp")
add_executable("increment" "increment.cpp")
add_executable("modulo" "modulo.cpp")
add_executable("multiplication" "multiplication.cpp")
add_executable("relational" "relational.cpp")
add_executable("shifts" "shifts.cpp")
add_executable("subtraction" "subtraction.cpp")
add_executable("template" "template.cpp")
add_executable("to-string-base10" "to-string-base10.cpp")
add_executable("to-string-base16" "to-string-base16.cpp")
add_executable("to-string-base2" "to-string-base2.cpp")
add_executable("to-string-base8" "to-string-base8.cpp")
# add_compile_definitions(USER_DEFINITION)

enable_testing()

foreach(test_src_code ${SOURCES})
get_filename_component(test_exec_name ${test_src_code} NAME_WE)
add_executable(${test_exec_name} ${test_src_code})
# target_compile_features(${test_exec_name} PRIVATE cxx_std_11)
target_compile_options(${test_exec_name} PRIVATE -fsanitize=address)
target_link_options(${test_exec_name} PRIVATE -fsanitize=address)
add_test(
NAME ${test_exec_name}
COMMAND $<TARGET_FILE:${test_exec_name}>
)
endforeach(test_src_code ${SOURCES})

0 comments on commit e8bed57

Please sign in to comment.