2 # Unit tests for the Unit Test Framework library
4 if(NOT DEFINED BOOST_TEST_ROOT_DIR)
5 message(FATAL_ERROR "Please use this file from the main CMakeLists.txt from the build/ folder")
8 if(NOT TARGET boost_test_framework OR NOT TARGET boost_test_framework_shared)
9 message(FATAL_ERROR "Please use this file from the main CMakeLists.txt from the build/ folder")
13 set(BOOST_TEST_UNITTESTS_FOLDER ${BOOST_TEST_ROOT_DIR}/test)
14 set(BOOST_TEST_EXAMPLES_FOLDER ${BOOST_TEST_ROOT_DIR}/example)
19 BOOST_UTF_DOC_EXAMPLES
21 ${BOOST_TEST_ROOT_DIR}/doc/examples/*.cpp)
23 foreach(_h IN LISTS BOOST_UTF_DOC_EXAMPLES)
24 get_filename_component(_hh ${_h} NAME_WE)
25 add_executable(doc-${_hh}
27 ${BOOST_TEST_ROOT_DIR}/doc/examples/${_hh}.output)
28 set_target_properties(doc-${_hh}
31 VS_DEBUGGER_WORKING_DIRECTORY ${BOOST_TEST_UNITTESTS_FOLDER})
32 target_include_directories(doc-${_hh}
34 ${BOOST_TEST_ROOT_DIR}/include/
35 ${BOOST_ROOT_DIR_ABS}/)
37 add_test(NAME doc-${_hh}-test
39 get_filename_component(_ext ${_h} EXT)
40 string(FIND ${_ext} "fail" _index_fail)
41 if(${_index_fail} GREATER -1)
42 set_tests_properties(doc-${_hh}-test
51 BOOST_TEST_UNITTESTS_DATASET
53 ${BOOST_TEST_UNITTESTS_FOLDER}/test-organization-ts/datasets-test/*.cpp
54 ${BOOST_TEST_UNITTESTS_FOLDER}/test-organization-ts/datasets-test/*.hpp)
55 add_executable(boost_test_datasets ${BOOST_TEST_UNITTESTS_DATASET})
56 set_target_properties(boost_test_datasets
59 VS_DEBUGGER_WORKING_DIRECTORY ${BOOST_TEST_UNITTESTS_FOLDER})
60 target_include_directories(boost_test_datasets
62 ${BOOST_TEST_ROOT_DIR}/include/
63 ${BOOST_ROOT_DIR_ABS}/)
64 target_link_libraries(boost_test_datasets boost_test_framework)
65 add_test(NAME bt-unittest-dataset
66 COMMAND boost_test_datasets)
72 set(BOOST_UTF_TESTS_FIND_FILES
83 foreach(_ts IN LISTS BOOST_UTF_TESTS_FIND_FILES)
86 _boost_utf_current_tsuite
87 ${BOOST_TEST_UNITTESTS_FOLDER}/${_ts}/*.cpp)
89 foreach(_h IN LISTS _boost_utf_current_tsuite)
90 get_filename_component(_hh ${_h} ABSOLUTE)
91 get_filename_component(_name ${_h} NAME_WE)
92 file(RELATIVE_PATH _v ${BOOST_TEST_UNITTESTS_FOLDER} ${_hh})
94 add_executable(${_name} ${_hh})
95 set_target_properties(${_name}
97 FOLDER "Unit tests/${_ts}"
98 VS_DEBUGGER_WORKING_DIRECTORY ${BOOST_TEST_UNITTESTS_FOLDER})
99 target_link_libraries(${_name}
101 boost_test_framework) # inaccurate
103 add_test(NAME bt-unittest-${_name}
107 unset(_boost_utf_current_tsuite)
109 endforeach() # test suite
117 unit_test_example_01.cpp,shared,fail
118 unit_test_example_02.cpp,static,fail
119 unit_test_example_03.cpp,static,fail
120 unit_test_example_04.cpp,shared,fail
121 unit_test_example_05.cpp,shared,fail
122 unit_test_example_06.cpp,shared,fail
123 unit_test_example_07.cpp,shared,run
124 unit_test_example_08.cpp,shared,run
125 unit_test_example_09_1.cpp,unit_test_example_09_2.cpp,shared,run
127 unit_test_example_10.cpp,static,fail
128 unit_test_example_11.cpp,static,fail
129 unit_test_example_12.cpp,static,link
130 unit_test_example_13.cpp,shared,run
131 unit_test_example_15.cpp,shared,fail
132 unit_test_example_16.cpp,shared,run
134 const_string_test.cpp,none,run
135 named_param_example.cpp,none,run
137 external_main_example_1.cpp,shared,fail
138 external_main_example_2.cpp,shared,fail
139 external_main_example_3.cpp,none,fail
140 filtering_example.cpp,static,fail
143 foreach(_var IN LISTS LIST_EXAMPLES)
144 string(REPLACE "," ";" _var_to_list "${_var}")
145 list(REVERSE _var_to_list)
146 list(GET _var_to_list 0 action)
147 list(GET _var_to_list 1 boost_test_type)
148 list(REMOVE_AT _var_to_list 0)
149 list(REMOVE_AT _var_to_list 0)
151 list(GET _var_to_list 0 first_file)
152 get_filename_component(_name_example "${first_file}" NAME_WE)
155 foreach(_file IN LISTS _var_to_list)
156 set(_list_files ${_list_files} ${BOOST_TEST_EXAMPLES_FOLDER}/${_file})
159 add_executable(${_name_example} ${_list_files})
160 set_target_properties(${_name_example}
163 VS_DEBUGGER_WORKING_DIRECTORY ${BOOST_TEST_UNITTESTS_FOLDER})
165 if("${boost_test_type}" STREQUAL "shared")
166 target_link_libraries(${_name_example}
168 boost_test_framework_shared)
169 elseif("${boost_test_type}" STREQUAL "static")
170 target_link_libraries(${_name_example}
172 boost_test_framework)
173 elseif(NOT "${boost_test_type}" STREQUAL "none")
174 message(FATAL_ERROR "Wrong action for example target '${_name_example}'")
177 if("${action}" STREQUAL "run" OR "${action}" STREQUAL "run-fail")
178 add_test(NAME bt-exampletest-${_name_example}
179 COMMAND ${_name_example})
181 if("${action}" STREQUAL "run-fail")
182 set_tests_properties(bt-exampletest-${_name_example}