1
0

init — unit tests

This commit is contained in:
Pcornat 2024-03-21 18:02:47 +01:00
parent 87f1181a1a
commit 22ebb857eb
Signed by: Pcornat
GPG Key ID: E0326CC678A00BDD
3 changed files with 43 additions and 2 deletions

View File

@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.28) cmake_minimum_required(VERSION 3.28 FATAL_ERROR)
project(raiiSafeCuda) project(raiiSafeCuda CXX)
option(ENABLE_TESTS "Enable tests' cmake target." ON)
find_package(CUDAToolkit REQUIRED) find_package(CUDAToolkit REQUIRED)
@ -13,3 +15,7 @@ set_target_properties(raiiSafeCuda PROPERTIES
CXX_EXTENSIONS OFF CXX_EXTENSIONS OFF
INTERPROCEDURAL_OPTIMIZATION ON INTERPROCEDURAL_OPTIMIZATION ON
) )
if (ENABLE_TESTS)
add_subdirectory(tests)
endif ()

26
tests/CMakeLists.txt Normal file
View File

@ -0,0 +1,26 @@
project(testsRaiiSafeCuda CXX)
find_package(Catch2)
if (NOT Catch2_FOUND)
message(STATUS "Using FetchContent to download and use Catch2")
include(FetchContent)
fetchcontent_declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2
GIT_TAG v3.5.3
EXCLUDE_FROM_ALL
OVERRIDE_FIND_PACKAGE
)
fetchcontent_makeavailable(Catch2)
find_package(Catch2 3 REQUIRED)
endif ()
include(CTest)
enable_testing()
include(Catch)
include(CatchAddTests)
add_executable(tests tests_stream.cpp)
target_link_libraries(tests Catch2::Catch2WithMain)
catch_discover_tests(tests WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

9
tests/tests_stream.cpp Normal file
View File

@ -0,0 +1,9 @@
//
// Created by postaron on 21/03/24.
//
#include <catch2/catch_all.hpp>
TEST_CASE("hello", "world") {
}