File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,3 +28,6 @@ add_executable(${PROJECT_NAME} src/main.cc)
2828target_compile_options (${PROJECT_NAME} PRIVATE -Wpedantic )
2929target_link_libraries (${PROJECT_NAME} PRIVATE hSim-lib CLI11::CLI11 fmt::fmt )
3030set_target_properties (${PROJECT_NAME} PROPERTIES OUTPUT_NAME hsim )
31+
32+ enable_testing ()
33+ add_subdirectory (test )
Original file line number Diff line number Diff line change 1+ add_subdirectory (unit )
Original file line number Diff line number Diff line change 1+ include (GoogleTest )
2+
3+ # Helpful macro to add unittest
4+ # Accepts src_file (with utest) as mandatory argument
5+ # and list of linked libraries after it
6+ macro (hsim_add_utest src_file )
7+ set (TEST_NAME "${src_file} _test" )
8+ add_executable (${TEST_NAME} ${src_file} )
9+
10+ target_link_libraries (${TEST_NAME} PRIVATE GTest::gtest_main hSIM::defaults )
11+ foreach (arg IN LISTS ARGN)
12+ target_link_libraries (${TEST_NAME} PRIVATE ${arg} )
13+ endforeach ()
14+ gtest_discover_tests (
15+ ${TEST_NAME}
16+ EXTRA_ARGS --gtest_color=yes
17+ PROPERTIES LABELS unit )
18+ endmacro ()
19+
20+ add_subdirectory (hello )
Original file line number Diff line number Diff line change 1+ hsim_add_utest (hello.cc )
Original file line number Diff line number Diff line change 1+ #include < gtest/gtest.h>
2+
3+ TEST (Simple, Hello) {
4+ ASSERT_TRUE (true );
5+ }
Original file line number Diff line number Diff line change @@ -21,3 +21,17 @@ CPMAddPackage(
2121 GIT_TAG Release_3.12
2222 EXCLUDE_FROM_ALL True
2323 SYSTEM True )
24+
25+
26+ # gtest
27+ CPMAddPackage (
28+ NAME
29+ googletest
30+ GITHUB_REPOSITORY
31+ google/googletest
32+ VERSION
33+ 1.16.0
34+ OPTIONS
35+ "INSTALL_GTEST OFF"
36+ EXCLUDE_FROM_ALL True
37+ SYSTEM True )
You can’t perform that action at this time.
0 commit comments