1
0
Fork 0
mirror of https://github.com/cosmo-sims/monofonIC.git synced 2024-09-19 17:03:45 +02:00

Created simple dummy unit tests.

This commit is contained in:
Michael Michaux 2020-08-26 11:14:41 +02:00
parent 7b40edf40a
commit 11a7cf54eb
4 changed files with 32 additions and 0 deletions

View file

@ -264,4 +264,14 @@ if(ENABLE_GENERICIO)
include(${CMAKE_CURRENT_SOURCE_DIR}/external/genericio.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/external/genericio.cmake)
target_link_libraries(${PRGNAME} PRIVATE genericio::genericio_mpi) target_link_libraries(${PRGNAME} PRIVATE genericio::genericio_mpi)
target_compile_definitions(${PRGNAME} PRIVATE "ENABLE_GENERICIO") target_compile_definitions(${PRGNAME} PRIVATE "ENABLE_GENERICIO")
endif()
################################### Testing ####################################
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
enable_testing()
endif()
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
add_subdirectory(testing)
endif() endif()

12
testing/CMakeLists.txt Normal file
View file

@ -0,0 +1,12 @@
# get all unit test sources
file(GLOB UNIT_TEST_SOURCES "${PROJECT_SOURCE_DIR}/testing/unit/*.cpp")
# create the tests
foreach(UNIT_TEST_CPP ${UNIT_TEST_SOURCES})
get_filename_component(UNIT_TEST_NAME ${UNIT_TEST_CPP} NAME_WE)
add_executable(${UNIT_TEST_NAME} ${UNIT_TEST_CPP})
add_test(NAME ${UNIT_TEST_NAME} COMMAND ${UNIT_TEST_NAME})
endforeach()
# add properties to specific tests
set_tests_properties(failure PROPERTIES WILL_FAIL true)

5
testing/unit/failure.cpp Normal file
View file

@ -0,0 +1,5 @@
#include <cstdlib>
int main(int argc, char const *argv[]) {
return EXIT_FAILURE;
}

5
testing/unit/success.cpp Normal file
View file

@ -0,0 +1,5 @@
#include <cstdlib>
int main(int argc, char const *argv[]) {
return EXIT_SUCCESS;
}