From 81c5ba9082df1b20169b193ef25774e4c2880031 Mon Sep 17 00:00:00 2001 From: Moritz Klammler Date: Fri, 16 Sep 2022 13:04:29 +0200 Subject: [PATCH] Define BOOST_TEST_MODULE in CMake This removes one #define from each unit test file and ensures consistency between file and module names. This consistency, was not strictly maintained before. I hope that any discrepancies were unintentional and that a 1:1 mapping is actually what is desired. Since the definition is now done at one single place, it would be easy to apply transformations like removing the 'test_' prefix or replacing '_' with '-' if this should be desired. --- tests/CMakeLists.txt | 1 + tests/test_comments.cpp | 1 - tests/test_datetime.cpp | 1 - tests/test_error_detection.cpp | 1 - tests/test_expect.cpp | 1 - tests/test_extended_conversions.cpp | 1 - tests/test_find.cpp | 1 - tests/test_find_or.cpp | 1 - tests/test_find_or_recursive.cpp | 1 - tests/test_format_error.cpp | 1 - tests/test_get.cpp | 1 - tests/test_get_or.cpp | 1 - tests/test_lex_boolean.cpp | 1 - tests/test_lex_datetime.cpp | 1 - tests/test_lex_floating.cpp | 1 - tests/test_lex_integer.cpp | 1 - tests/test_lex_key_comment.cpp | 1 - tests/test_lex_string.cpp | 1 - tests/test_literals.cpp | 1 - tests/test_parse_array.cpp | 1 - tests/test_parse_boolean.cpp | 1 - tests/test_parse_datetime.cpp | 1 - tests/test_parse_file.cpp | 1 - tests/test_parse_floating.cpp | 1 - tests/test_parse_inline_table.cpp | 1 - tests/test_parse_integer.cpp | 1 - tests/test_parse_key.cpp | 1 - tests/test_parse_string.cpp | 1 - tests/test_parse_table.cpp | 1 - tests/test_parse_table_key.cpp | 1 - tests/test_parse_unicode.cpp | 1 - tests/test_result.cpp | 1 - tests/test_serialize_file.cpp | 1 - tests/test_string.cpp | 1 - tests/test_traits.cpp | 1 - tests/test_utility.cpp | 1 - tests/test_value.cpp | 1 - 37 files changed, 1 insertion(+), 36 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 11e449e..332eaa8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -248,6 +248,7 @@ foreach(TEST_NAME ${TEST_NAMES}) add_executable(${TEST_NAME} ${TEST_NAME}.cpp) target_link_libraries(${TEST_NAME} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} toml11::toml11) target_include_directories(${TEST_NAME} SYSTEM PRIVATE ${Boost_INCLUDE_DIRS}) + target_compile_definitions(${TEST_NAME} PRIVATE "BOOST_TEST_MODULE=\"${TEST_NAME}\"") # to compile tests with ... if(TOML11_REQUIRE_FILESYSTEM_LIBRARY) diff --git a/tests/test_comments.cpp b/tests/test_comments.cpp index a5765dc..751e240 100644 --- a/tests/test_comments.cpp +++ b/tests/test_comments.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_comments" #include "unit_test.hpp" #include diff --git a/tests/test_datetime.cpp b/tests/test_datetime.cpp index 1759c34..df0ccb9 100644 --- a/tests/test_datetime.cpp +++ b/tests/test_datetime.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_datetime" #include "unit_test.hpp" #include diff --git a/tests/test_error_detection.cpp b/tests/test_error_detection.cpp index 3364d16..9fba8a7 100644 --- a/tests/test_error_detection.cpp +++ b/tests/test_error_detection.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_error_detection" #include "unit_test.hpp" #include diff --git a/tests/test_expect.cpp b/tests/test_expect.cpp index 131c1cc..bb2646b 100644 --- a/tests/test_expect.cpp +++ b/tests/test_expect.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_expect" #include "unit_test.hpp" #include diff --git a/tests/test_extended_conversions.cpp b/tests/test_extended_conversions.cpp index 28974d7..3e2c94a 100644 --- a/tests/test_extended_conversions.cpp +++ b/tests/test_extended_conversions.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_extended_conversions" #include "unit_test.hpp" #include diff --git a/tests/test_find.cpp b/tests/test_find.cpp index 682ce87..54ab3c9 100644 --- a/tests/test_find.cpp +++ b/tests/test_find.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_find" #include "unit_test.hpp" #include diff --git a/tests/test_find_or.cpp b/tests/test_find_or.cpp index 8f1eb73..fc1a469 100644 --- a/tests/test_find_or.cpp +++ b/tests/test_find_or.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_find_or" #include "unit_test.hpp" #include diff --git a/tests/test_find_or_recursive.cpp b/tests/test_find_or_recursive.cpp index 22fcfb5..20b595b 100644 --- a/tests/test_find_or_recursive.cpp +++ b/tests/test_find_or_recursive.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_find_or_recursive" #include "unit_test.hpp" #include diff --git a/tests/test_format_error.cpp b/tests/test_format_error.cpp index d347d85..f539b47 100644 --- a/tests/test_format_error.cpp +++ b/tests/test_format_error.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_format_error" #include "unit_test.hpp" #include diff --git a/tests/test_get.cpp b/tests/test_get.cpp index eaae50e..e2eb3ab 100644 --- a/tests/test_get.cpp +++ b/tests/test_get.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_get" #include "unit_test.hpp" #include diff --git a/tests/test_get_or.cpp b/tests/test_get_or.cpp index 68c4884..878ad1c 100644 --- a/tests/test_get_or.cpp +++ b/tests/test_get_or.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_get_or" #include "unit_test.hpp" #include diff --git a/tests/test_lex_boolean.cpp b/tests/test_lex_boolean.cpp index b9f830c..2163178 100644 --- a/tests/test_lex_boolean.cpp +++ b/tests/test_lex_boolean.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_lex_boolean" #include "unit_test.hpp" #include diff --git a/tests/test_lex_datetime.cpp b/tests/test_lex_datetime.cpp index 75e1c05..e40f124 100644 --- a/tests/test_lex_datetime.cpp +++ b/tests/test_lex_datetime.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_lex_datetime" #include "unit_test.hpp" #include diff --git a/tests/test_lex_floating.cpp b/tests/test_lex_floating.cpp index 1654874..0208b22 100644 --- a/tests/test_lex_floating.cpp +++ b/tests/test_lex_floating.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_lex_floating" #include "unit_test.hpp" #include diff --git a/tests/test_lex_integer.cpp b/tests/test_lex_integer.cpp index c3171c7..7220a3e 100644 --- a/tests/test_lex_integer.cpp +++ b/tests/test_lex_integer.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_lex_integer" #include "unit_test.hpp" #include diff --git a/tests/test_lex_key_comment.cpp b/tests/test_lex_key_comment.cpp index 2315d86..83c88b3 100644 --- a/tests/test_lex_key_comment.cpp +++ b/tests/test_lex_key_comment.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "lex_key_comment_test" #include "unit_test.hpp" #include diff --git a/tests/test_lex_string.cpp b/tests/test_lex_string.cpp index fb42ee3..02138f2 100644 --- a/tests/test_lex_string.cpp +++ b/tests/test_lex_string.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_lex_string" #include "unit_test.hpp" #include diff --git a/tests/test_literals.cpp b/tests/test_literals.cpp index e550845..6186993 100644 --- a/tests/test_literals.cpp +++ b/tests/test_literals.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_literals" #include "unit_test.hpp" #include diff --git a/tests/test_parse_array.cpp b/tests/test_parse_array.cpp index 9943a98..a3e2886 100644 --- a/tests/test_parse_array.cpp +++ b/tests/test_parse_array.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "parse_array_test" #include "unit_test.hpp" #include diff --git a/tests/test_parse_boolean.cpp b/tests/test_parse_boolean.cpp index f6cb26f..f0b87b1 100644 --- a/tests/test_parse_boolean.cpp +++ b/tests/test_parse_boolean.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_parse_boolean" #include "unit_test.hpp" #include diff --git a/tests/test_parse_datetime.cpp b/tests/test_parse_datetime.cpp index e4b2d23..dc7e44c 100644 --- a/tests/test_parse_datetime.cpp +++ b/tests/test_parse_datetime.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "parse_datetime_test" #include "unit_test.hpp" #include diff --git a/tests/test_parse_file.cpp b/tests/test_parse_file.cpp index 0bce6b7..a3559de 100644 --- a/tests/test_parse_file.cpp +++ b/tests/test_parse_file.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_parse_file" #include "unit_test.hpp" #include diff --git a/tests/test_parse_floating.cpp b/tests/test_parse_floating.cpp index dbe012d..c3efb02 100644 --- a/tests/test_parse_floating.cpp +++ b/tests/test_parse_floating.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "parse_floating_test" #include "unit_test.hpp" #include diff --git a/tests/test_parse_inline_table.cpp b/tests/test_parse_inline_table.cpp index dad3257..cde30be 100644 --- a/tests/test_parse_inline_table.cpp +++ b/tests/test_parse_inline_table.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "parse_inline_table_test" #include "unit_test.hpp" #include diff --git a/tests/test_parse_integer.cpp b/tests/test_parse_integer.cpp index 2d8e97f..bc3951b 100644 --- a/tests/test_parse_integer.cpp +++ b/tests/test_parse_integer.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "parse_integer_test" #include "unit_test.hpp" #include diff --git a/tests/test_parse_key.cpp b/tests/test_parse_key.cpp index 24e8f02..14f1847 100644 --- a/tests/test_parse_key.cpp +++ b/tests/test_parse_key.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "parse_key_test" #include "unit_test.hpp" #include diff --git a/tests/test_parse_string.cpp b/tests/test_parse_string.cpp index 63e734e..0865b95 100644 --- a/tests/test_parse_string.cpp +++ b/tests/test_parse_string.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "parse_string_test" #include "unit_test.hpp" #include diff --git a/tests/test_parse_table.cpp b/tests/test_parse_table.cpp index f5b8856..bec4491 100644 --- a/tests/test_parse_table.cpp +++ b/tests/test_parse_table.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "parse_table_test" #include "unit_test.hpp" #include diff --git a/tests/test_parse_table_key.cpp b/tests/test_parse_table_key.cpp index 18ba2ea..8a526ab 100644 --- a/tests/test_parse_table_key.cpp +++ b/tests/test_parse_table_key.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "parse_table_key_test" #include "unit_test.hpp" #include diff --git a/tests/test_parse_unicode.cpp b/tests/test_parse_unicode.cpp index 0f891e9..e33713b 100644 --- a/tests/test_parse_unicode.cpp +++ b/tests/test_parse_unicode.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_parse_unicode" #include "unit_test.hpp" #include diff --git a/tests/test_result.cpp b/tests/test_result.cpp index 47332d2..2004c53 100644 --- a/tests/test_result.cpp +++ b/tests/test_result.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_result" #include "unit_test.hpp" #include diff --git a/tests/test_serialize_file.cpp b/tests/test_serialize_file.cpp index d26ce69..87d0cda 100644 --- a/tests/test_serialize_file.cpp +++ b/tests/test_serialize_file.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_serialize_file" #include "unit_test.hpp" #include diff --git a/tests/test_string.cpp b/tests/test_string.cpp index 2ed2c17..efb1dd4 100644 --- a/tests/test_string.cpp +++ b/tests/test_string.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_string" #include "unit_test.hpp" #include diff --git a/tests/test_traits.cpp b/tests/test_traits.cpp index ce73d3d..149252d 100644 --- a/tests/test_traits.cpp +++ b/tests/test_traits.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_traits" #include "unit_test.hpp" #include diff --git a/tests/test_utility.cpp b/tests/test_utility.cpp index 37302cb..6e58430 100644 --- a/tests/test_utility.cpp +++ b/tests/test_utility.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_acceptor" #include "unit_test.hpp" #include diff --git a/tests/test_value.cpp b/tests/test_value.cpp index 29781ad..fca014e 100644 --- a/tests/test_value.cpp +++ b/tests/test_value.cpp @@ -1,4 +1,3 @@ -#define BOOST_TEST_MODULE "test_value" #include "unit_test.hpp" #include