From 22ebb857eb3d9f62d313f927545d46f8fdd8cc43 Mon Sep 17 00:00:00 2001 From: Pcornat Date: Thu, 21 Mar 2024 18:02:47 +0100 Subject: [PATCH] =?UTF-8?q?init=20=E2=80=94=20unit=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 10 ++++++++-- tests/CMakeLists.txt | 26 ++++++++++++++++++++++++++ tests/tests_stream.cpp | 9 +++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 tests/CMakeLists.txt create mode 100644 tests/tests_stream.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ad1f01..c25b0a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ -cmake_minimum_required(VERSION 3.28) -project(raiiSafeCuda) +cmake_minimum_required(VERSION 3.28 FATAL_ERROR) +project(raiiSafeCuda CXX) + +option(ENABLE_TESTS "Enable tests' cmake target." ON) find_package(CUDAToolkit REQUIRED) @@ -13,3 +15,7 @@ set_target_properties(raiiSafeCuda PROPERTIES CXX_EXTENSIONS OFF INTERPROCEDURAL_OPTIMIZATION ON ) + +if (ENABLE_TESTS) + add_subdirectory(tests) +endif () diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..0f967ee --- /dev/null +++ b/tests/CMakeLists.txt @@ -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}) diff --git a/tests/tests_stream.cpp b/tests/tests_stream.cpp new file mode 100644 index 0000000..2e71430 --- /dev/null +++ b/tests/tests_stream.cpp @@ -0,0 +1,9 @@ +// +// Created by postaron on 21/03/24. +// + +#include + +TEST_CASE("hello", "world") { + +}