fcs-proj / FastCaloSim

An experiment-independent library for fast calorimeter simulation
Apache License 2.0
2 stars 0 forks source link

Add basic tests #8

Closed jbeirer closed 6 months ago

jbeirer commented 6 months ago

This MR:

Note: in the current test setup, only exported classes can be tested, as anything hidden from the consumer will miss symbols in the testing.

There is a workaround to test classes not part of the api by creating a static test library that contains all symbols:

# ---- Define FastCaloSim_test library ----

# Assuming source files and include paths from the main project
add_library(FastCaloSim_test STATIC 
    $<TARGET_OBJECTS:FastCaloSim::FastCaloSim>
)
target_include_directories(FastCaloSim_test PUBLIC ${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/export)

target_link_libraries(FastCaloSim_test PRIVATE FastCaloSim::FastCaloSim)

and then for the tests

target_link_libraries(${suite_name}_tests PRIVATE FastCaloSim_test GTest::gtest_main)

In principle though, we should write the library in a way that we can test most/all functionality with the public API. To be decided in the future