IAP GITLAB

Skip to content
Snippets Groups Projects
Commit f567b2ef authored by ralfulrich's avatar ralfulrich
Browse files

first unit testing examples

parent b72e9918
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ set (CMAKE_INSTALL_MESSAGE LAZY) ...@@ -7,7 +7,7 @@ set (CMAKE_INSTALL_MESSAGE LAZY)
# --std=c++14 # --std=c++14
set (CMAKE_CXX_STANDARD 14) set (CMAKE_CXX_STANDARD 14)
enable_testing ()
#add_custom_target (corsika_pre_build) #add_custom_target (corsika_pre_build)
#add_custom_command (TARGET corsika_pre_build PRE_BUILD COMMAND "${PROJECT_SOURCE_DIR}/pre_compile.py") #add_custom_command (TARGET corsika_pre_build PRE_BUILD COMMAND "${PROJECT_SOURCE_DIR}/pre_compile.py")
......
...@@ -17,8 +17,15 @@ target_include_directories (CORSIKAgeometry INTERFACE ${EIGEN3_INCLUDE_DIR}) ...@@ -17,8 +17,15 @@ target_include_directories (CORSIKAgeometry INTERFACE ${EIGEN3_INCLUDE_DIR})
target_include_directories (CORSIKAgeometry INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/Framework> target_include_directories (CORSIKAgeometry INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/Framework>
$<INSTALL_INTERFACE:include/Framework> $<INSTALL_INTERFACE:include/Framework>
) )
install (TARGETS CORSIKAgeometry install (TARGETS CORSIKAgeometry
LIBRARY DESTINATION lib LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include/Geometry) PUBLIC_HEADER DESTINATION include/Geometry)
# code testing
add_executable (testGeometry testGeometry.cc)
target_link_libraries (testGeometry CORSIKAgeometry CORSIKAunits CORSIKAthirdparty) # for catch2
add_test (NAME testGeometry COMMAND testGeometry -o report.xml -r junit)
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#include <ThirdParty/catch2/catch.hpp>
#include <Units/PhysicalUnits.h>
using namespace phys::units;
using namespace phys::units::io;
using namespace phys::units::literals;
TEST_CASE( "PhysicalUnits", "[Units]" )
{
SECTION( "sectionOne" )
{
REQUIRE( 1_m/1_m == 1 );
}
SECTION( "sectionTwo" )
{
REQUIRE_FALSE( 1_m/1_m == 2 );
}
SECTION( "sectionThree" )
{
REQUIRE( 1_s/1_s == 2 );
}
}
...@@ -11,3 +11,8 @@ target_include_directories (CORSIKAunits ...@@ -11,3 +11,8 @@ target_include_directories (CORSIKAunits
install (FILES PhysicalUnits.h DESTINATION include/Units) install (FILES PhysicalUnits.h DESTINATION include/Units)
# code testing
add_executable (testUnits testUnits.cc)
target_link_libraries (testUnits CORSIKAunits CORSIKAthirdparty) # for catch2
add_test(NAME testUnits COMMAND testUnits)
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#include <ThirdParty/catch2/catch.hpp>
#include <Units/PhysicalUnits.h>
using namespace phys::units;
using namespace phys::units::io;
using namespace phys::units::literals;
TEST_CASE( "PhysicalUnits", "[Units]" ) {
REQUIRE( 1_m/1_m == 1 );
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment