From 10fd14f8b91b68153f677c58cddfbd6734afc50e Mon Sep 17 00:00:00 2001 From: Moritz Klammler Date: Fri, 16 Sep 2022 13:16:01 +0200 Subject: [PATCH] Consistent unit test header inclusion order This patch consistently changes the inclusion order for unit test files to the following: 1. The header of the unit under test (using <> includes). 2. The unit_test.hpp header (using "" includes). 3. Any additional auxiliary test headers (using "" includes and sorted alphabetically). 4. Additional system headers needed for the test (using <> includes and sorted alphabetically). 5. Conditionally included system headers (using <> includes). Putting the unit under test's header at the very beginning has the advantage of also testing that the header is self-contained. It also makes it very quick to tell what unit is tested in this file. --- tests/check.cpp | 3 ++- tests/check_serialization.cpp | 5 +++-- tests/check_toml_test.cpp | 5 +++-- tests/test_comments.cpp | 4 ++-- tests/test_datetime.cpp | 4 ++-- tests/test_error_detection.cpp | 5 +++-- tests/test_expect.cpp | 9 +++++---- tests/test_extended_conversions.cpp | 3 ++- tests/test_find.cpp | 15 ++++++++------- tests/test_find_or.cpp | 12 +++++++----- tests/test_find_or_recursive.cpp | 12 +++++++----- tests/test_format_error.cpp | 3 ++- tests/test_get.cpp | 12 +++++++----- tests/test_get_or.cpp | 12 +++++++----- tests/test_lex_boolean.cpp | 4 ++-- tests/test_lex_datetime.cpp | 4 ++-- tests/test_lex_floating.cpp | 7 ++++--- tests/test_lex_integer.cpp | 4 ++-- tests/test_lex_key_comment.cpp | 4 ++-- tests/test_lex_string.cpp | 4 ++-- tests/test_literals.cpp | 3 ++- tests/test_parse_array.cpp | 4 ++-- tests/test_parse_boolean.cpp | 4 ++-- tests/test_parse_datetime.cpp | 4 ++-- tests/test_parse_file.cpp | 9 +++++---- tests/test_parse_floating.cpp | 7 ++++--- tests/test_parse_inline_table.cpp | 4 ++-- tests/test_parse_integer.cpp | 4 ++-- tests/test_parse_key.cpp | 4 ++-- tests/test_parse_string.cpp | 4 ++-- tests/test_parse_table.cpp | 6 +++--- tests/test_parse_table_key.cpp | 4 ++-- tests/test_parse_unicode.cpp | 5 +++-- tests/test_result.cpp | 3 ++- tests/test_serialize_file.cpp | 7 ++++--- tests/test_string.cpp | 4 ++-- tests/test_traits.cpp | 12 ++++++------ tests/test_utility.cpp | 5 +++-- tests/test_value.cpp | 3 ++- 39 files changed, 126 insertions(+), 101 deletions(-) diff --git a/tests/check.cpp b/tests/check.cpp index a271f3f..bf67775 100644 --- a/tests/check.cpp +++ b/tests/check.cpp @@ -1,4 +1,5 @@ -#include "toml.hpp" +#include + #include #include diff --git a/tests/check_serialization.cpp b/tests/check_serialization.cpp index 6f60103..e97d51b 100644 --- a/tests/check_serialization.cpp +++ b/tests/check_serialization.cpp @@ -1,6 +1,7 @@ -#include "toml.hpp" -#include +#include + #include +#include int main(int argc, char **argv) { diff --git a/tests/check_toml_test.cpp b/tests/check_toml_test.cpp index 9c57572..51404c9 100644 --- a/tests/check_toml_test.cpp +++ b/tests/check_toml_test.cpp @@ -1,6 +1,7 @@ -#include "toml.hpp" -#include +#include + #include +#include struct json_serializer { diff --git a/tests/test_comments.cpp b/tests/test_comments.cpp index 751e240..2d2b6a6 100644 --- a/tests/test_comments.cpp +++ b/tests/test_comments.cpp @@ -1,7 +1,7 @@ -#include "unit_test.hpp" - #include +#include "unit_test.hpp" + BOOST_AUTO_TEST_CASE(test_comment_before) { { diff --git a/tests/test_datetime.cpp b/tests/test_datetime.cpp index df0ccb9..bbbcc42 100644 --- a/tests/test_datetime.cpp +++ b/tests/test_datetime.cpp @@ -1,7 +1,7 @@ -#include "unit_test.hpp" - #include +#include "unit_test.hpp" + BOOST_AUTO_TEST_CASE(test_local_date) { const toml::local_date date(2018, toml::month_t::Jan, 1); diff --git a/tests/test_error_detection.cpp b/tests/test_error_detection.cpp index 9fba8a7..5e39ef6 100644 --- a/tests/test_error_detection.cpp +++ b/tests/test_error_detection.cpp @@ -1,8 +1,9 @@ +#include + #include "unit_test.hpp" -#include -#include #include +#include BOOST_AUTO_TEST_CASE(test_detect_empty_key) { diff --git a/tests/test_expect.cpp b/tests/test_expect.cpp index bb2646b..308d4fb 100644 --- a/tests/test_expect.cpp +++ b/tests/test_expect.cpp @@ -1,11 +1,12 @@ +#include + #include "unit_test.hpp" -#include +#include +#include +#include #include #include -#include -#include -#include BOOST_AUTO_TEST_CASE(test_expect) { diff --git a/tests/test_extended_conversions.cpp b/tests/test_extended_conversions.cpp index 3e2c94a..1b21264 100644 --- a/tests/test_extended_conversions.cpp +++ b/tests/test_extended_conversions.cpp @@ -1,6 +1,7 @@ +#include + #include "unit_test.hpp" -#include #include #include diff --git a/tests/test_find.cpp b/tests/test_find.cpp index 54ab3c9..944b8e8 100644 --- a/tests/test_find.cpp +++ b/tests/test_find.cpp @@ -1,15 +1,17 @@ +#include + #include "unit_test.hpp" -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include + #if TOML11_CPLUSPLUS_STANDARD_VERSION >= 201703L #include #endif -#include using test_value_types = std::tuple< toml::basic_value, @@ -823,4 +825,3 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(test_get_toml_offset_datetime, value_type, test_va BOOST_TEST(tm.tm_sec == 0); } } - diff --git a/tests/test_find_or.cpp b/tests/test_find_or.cpp index fc1a469..8348f2f 100644 --- a/tests/test_find_or.cpp +++ b/tests/test_find_or.cpp @@ -1,12 +1,14 @@ +#include + #include "unit_test.hpp" -#include -#include -#include -#include -#include #include +#include +#include +#include #include +#include + #if TOML11_CPLUSPLUS_STANDARD_VERSION >= 201703L #include #endif diff --git a/tests/test_find_or_recursive.cpp b/tests/test_find_or_recursive.cpp index 20b595b..41e8a05 100644 --- a/tests/test_find_or_recursive.cpp +++ b/tests/test_find_or_recursive.cpp @@ -1,12 +1,14 @@ +#include + #include "unit_test.hpp" -#include -#include -#include -#include -#include #include +#include +#include +#include #include +#include + #if TOML11_CPLUSPLUS_STANDARD_VERSION >= 201703L #include #endif diff --git a/tests/test_format_error.cpp b/tests/test_format_error.cpp index f539b47..c00f845 100644 --- a/tests/test_format_error.cpp +++ b/tests/test_format_error.cpp @@ -1,6 +1,7 @@ +#include + #include "unit_test.hpp" -#include #include // to check it successfully compiles. it does not check the formatted string. diff --git a/tests/test_get.cpp b/tests/test_get.cpp index e2eb3ab..0db4abf 100644 --- a/tests/test_get.cpp +++ b/tests/test_get.cpp @@ -1,12 +1,14 @@ +#include + #include "unit_test.hpp" -#include -#include -#include -#include -#include #include +#include +#include +#include #include +#include + #if TOML11_CPLUSPLUS_STANDARD_VERSION >= 201703L #include #endif diff --git a/tests/test_get_or.cpp b/tests/test_get_or.cpp index 878ad1c..9ecb36e 100644 --- a/tests/test_get_or.cpp +++ b/tests/test_get_or.cpp @@ -1,12 +1,14 @@ +#include + #include "unit_test.hpp" -#include -#include -#include -#include -#include #include +#include +#include +#include #include +#include + #if TOML11_CPLUSPLUS_STANDARD_VERSION >= 201703L #include #endif diff --git a/tests/test_lex_boolean.cpp b/tests/test_lex_boolean.cpp index 2163178..deecffe 100644 --- a/tests/test_lex_boolean.cpp +++ b/tests/test_lex_boolean.cpp @@ -1,6 +1,6 @@ -#include "unit_test.hpp" - #include + +#include "unit_test.hpp" #include "test_lex_aux.hpp" using namespace toml; diff --git a/tests/test_lex_datetime.cpp b/tests/test_lex_datetime.cpp index e40f124..8e33d38 100644 --- a/tests/test_lex_datetime.cpp +++ b/tests/test_lex_datetime.cpp @@ -1,6 +1,6 @@ -#include "unit_test.hpp" - #include + +#include "unit_test.hpp" #include "test_lex_aux.hpp" using namespace toml; diff --git a/tests/test_lex_floating.cpp b/tests/test_lex_floating.cpp index 0208b22..8c9cd20 100644 --- a/tests/test_lex_floating.cpp +++ b/tests/test_lex_floating.cpp @@ -1,9 +1,10 @@ -#include "unit_test.hpp" - #include -#include + +#include "unit_test.hpp" #include "test_lex_aux.hpp" +#include + using namespace toml; using namespace detail; diff --git a/tests/test_lex_integer.cpp b/tests/test_lex_integer.cpp index 7220a3e..50b9178 100644 --- a/tests/test_lex_integer.cpp +++ b/tests/test_lex_integer.cpp @@ -1,6 +1,6 @@ -#include "unit_test.hpp" - #include + +#include "unit_test.hpp" #include "test_lex_aux.hpp" using namespace toml; diff --git a/tests/test_lex_key_comment.cpp b/tests/test_lex_key_comment.cpp index 83c88b3..da123a4 100644 --- a/tests/test_lex_key_comment.cpp +++ b/tests/test_lex_key_comment.cpp @@ -1,6 +1,6 @@ -#include "unit_test.hpp" - #include + +#include "unit_test.hpp" #include "test_lex_aux.hpp" using namespace toml; diff --git a/tests/test_lex_string.cpp b/tests/test_lex_string.cpp index 02138f2..f8f2424 100644 --- a/tests/test_lex_string.cpp +++ b/tests/test_lex_string.cpp @@ -1,6 +1,6 @@ -#include "unit_test.hpp" - #include + +#include "unit_test.hpp" #include "test_lex_aux.hpp" using namespace toml; diff --git a/tests/test_literals.cpp b/tests/test_literals.cpp index 6186993..de81f39 100644 --- a/tests/test_literals.cpp +++ b/tests/test_literals.cpp @@ -1,6 +1,7 @@ +#include + #include "unit_test.hpp" -#include #include BOOST_AUTO_TEST_CASE(test_file_as_literal) diff --git a/tests/test_parse_array.cpp b/tests/test_parse_array.cpp index a3e2886..053d4c5 100644 --- a/tests/test_parse_array.cpp +++ b/tests/test_parse_array.cpp @@ -1,6 +1,6 @@ -#include "unit_test.hpp" - #include + +#include "unit_test.hpp" #include "test_parse_aux.hpp" using namespace toml; diff --git a/tests/test_parse_boolean.cpp b/tests/test_parse_boolean.cpp index f0b87b1..5ed128c 100644 --- a/tests/test_parse_boolean.cpp +++ b/tests/test_parse_boolean.cpp @@ -1,6 +1,6 @@ -#include "unit_test.hpp" - #include + +#include "unit_test.hpp" #include "test_parse_aux.hpp" using namespace toml; diff --git a/tests/test_parse_datetime.cpp b/tests/test_parse_datetime.cpp index dc7e44c..46bd78c 100644 --- a/tests/test_parse_datetime.cpp +++ b/tests/test_parse_datetime.cpp @@ -1,6 +1,6 @@ -#include "unit_test.hpp" - #include + +#include "unit_test.hpp" #include "test_parse_aux.hpp" using namespace toml; diff --git a/tests/test_parse_file.cpp b/tests/test_parse_file.cpp index a3559de..cea5387 100644 --- a/tests/test_parse_file.cpp +++ b/tests/test_parse_file.cpp @@ -1,10 +1,11 @@ +#include + #include "unit_test.hpp" -#include -#include -#include -#include #include +#include +#include +#include BOOST_AUTO_TEST_CASE(test_example) { diff --git a/tests/test_parse_floating.cpp b/tests/test_parse_floating.cpp index c3efb02..5c05bab 100644 --- a/tests/test_parse_floating.cpp +++ b/tests/test_parse_floating.cpp @@ -1,9 +1,10 @@ -#include "unit_test.hpp" - #include -#include + +#include "unit_test.hpp" #include "test_parse_aux.hpp" +#include + using namespace toml; using namespace detail; diff --git a/tests/test_parse_inline_table.cpp b/tests/test_parse_inline_table.cpp index cde30be..9217a23 100644 --- a/tests/test_parse_inline_table.cpp +++ b/tests/test_parse_inline_table.cpp @@ -1,6 +1,6 @@ -#include "unit_test.hpp" - #include + +#include "unit_test.hpp" #include "test_parse_aux.hpp" using namespace toml; diff --git a/tests/test_parse_integer.cpp b/tests/test_parse_integer.cpp index bc3951b..423961f 100644 --- a/tests/test_parse_integer.cpp +++ b/tests/test_parse_integer.cpp @@ -1,6 +1,6 @@ -#include "unit_test.hpp" - #include + +#include "unit_test.hpp" #include "test_parse_aux.hpp" using namespace toml; diff --git a/tests/test_parse_key.cpp b/tests/test_parse_key.cpp index 14f1847..3af0eaa 100644 --- a/tests/test_parse_key.cpp +++ b/tests/test_parse_key.cpp @@ -1,6 +1,6 @@ -#include "unit_test.hpp" - #include + +#include "unit_test.hpp" #include "test_parse_aux.hpp" using namespace toml; diff --git a/tests/test_parse_string.cpp b/tests/test_parse_string.cpp index 0865b95..bf381e3 100644 --- a/tests/test_parse_string.cpp +++ b/tests/test_parse_string.cpp @@ -1,6 +1,6 @@ -#include "unit_test.hpp" - #include + +#include "unit_test.hpp" #include "test_parse_aux.hpp" using namespace toml; diff --git a/tests/test_parse_table.cpp b/tests/test_parse_table.cpp index bec4491..0fd54c7 100644 --- a/tests/test_parse_table.cpp +++ b/tests/test_parse_table.cpp @@ -1,7 +1,7 @@ -#include "unit_test.hpp" - -#include #include +#include + +#include "unit_test.hpp" #include "test_parse_aux.hpp" using namespace toml; diff --git a/tests/test_parse_table_key.cpp b/tests/test_parse_table_key.cpp index 8a526ab..a921c96 100644 --- a/tests/test_parse_table_key.cpp +++ b/tests/test_parse_table_key.cpp @@ -1,6 +1,6 @@ -#include "unit_test.hpp" - #include + +#include "unit_test.hpp" #include "test_parse_aux.hpp" using namespace toml; diff --git a/tests/test_parse_unicode.cpp b/tests/test_parse_unicode.cpp index e33713b..8bc4253 100644 --- a/tests/test_parse_unicode.cpp +++ b/tests/test_parse_unicode.cpp @@ -1,8 +1,9 @@ +#include + #include "unit_test.hpp" -#include -#include #include +#include BOOST_AUTO_TEST_CASE(test_hard_example_unicode) { diff --git a/tests/test_result.cpp b/tests/test_result.cpp index 2004c53..ff43fe0 100644 --- a/tests/test_result.cpp +++ b/tests/test_result.cpp @@ -1,7 +1,8 @@ +#include + #include "unit_test.hpp" #include -#include BOOST_AUTO_TEST_CASE(test_construct) { diff --git a/tests/test_serialize_file.cpp b/tests/test_serialize_file.cpp index 87d0cda..b6b8acb 100644 --- a/tests/test_serialize_file.cpp +++ b/tests/test_serialize_file.cpp @@ -1,10 +1,11 @@ +#include + #include "unit_test.hpp" -#include #include -#include -#include #include +#include +#include #include template +#include "unit_test.hpp" + BOOST_AUTO_TEST_CASE(test_basic_string) { { diff --git a/tests/test_traits.cpp b/tests/test_traits.cpp index 149252d..4d5e3e2 100644 --- a/tests/test_traits.cpp +++ b/tests/test_traits.cpp @@ -1,16 +1,16 @@ -#include "unit_test.hpp" - #include -#include -#include -#include +#include "unit_test.hpp" + #include +#include +#include +#include #include #include +#include #include #include -#include struct dummy_type{}; diff --git a/tests/test_utility.cpp b/tests/test_utility.cpp index 6e58430..c67e3b8 100644 --- a/tests/test_utility.cpp +++ b/tests/test_utility.cpp @@ -1,8 +1,9 @@ +#include + #include "unit_test.hpp" -#include -#include #include +#include BOOST_AUTO_TEST_CASE(test_try_reserve) { diff --git a/tests/test_value.cpp b/tests/test_value.cpp index fca014e..296d343 100644 --- a/tests/test_value.cpp +++ b/tests/test_value.cpp @@ -1,6 +1,7 @@ +#include + #include "unit_test.hpp" -#include #include #include