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.
This commit is contained in:
Moritz Klammler 2022-09-16 13:16:01 +02:00
parent 81c5ba9082
commit 10fd14f8b9
39 changed files with 126 additions and 101 deletions

View File

@ -1,4 +1,5 @@
#include "toml.hpp"
#include <toml.hpp>
#include <iostream>
#include <iomanip>

View File

@ -1,6 +1,7 @@
#include "toml.hpp"
#include <iostream>
#include <toml.hpp>
#include <iomanip>
#include <iostream>
int main(int argc, char **argv)
{

View File

@ -1,6 +1,7 @@
#include "toml.hpp"
#include <iostream>
#include <toml.hpp>
#include <iomanip>
#include <iostream>
struct json_serializer
{

View File

@ -1,7 +1,7 @@
#include "unit_test.hpp"
#include <toml.hpp>
#include "unit_test.hpp"
BOOST_AUTO_TEST_CASE(test_comment_before)
{
{

View File

@ -1,7 +1,7 @@
#include "unit_test.hpp"
#include <toml/datetime.hpp>
#include "unit_test.hpp"
BOOST_AUTO_TEST_CASE(test_local_date)
{
const toml::local_date date(2018, toml::month_t::Jan, 1);

View File

@ -1,8 +1,9 @@
#include <toml.hpp>
#include "unit_test.hpp"
#include <toml.hpp>
#include <iostream>
#include <fstream>
#include <iostream>
BOOST_AUTO_TEST_CASE(test_detect_empty_key)
{

View File

@ -1,11 +1,12 @@
#include <toml.hpp>
#include "unit_test.hpp"
#include <toml.hpp>
#include <array>
#include <deque>
#include <list>
#include <map>
#include <unordered_map>
#include <list>
#include <deque>
#include <array>
BOOST_AUTO_TEST_CASE(test_expect)
{

View File

@ -1,6 +1,7 @@
#include <toml.hpp>
#include "unit_test.hpp"
#include <toml.hpp>
#include <deque>
#include <map>

View File

@ -1,15 +1,17 @@
#include <toml.hpp>
#include "unit_test.hpp"
#include <toml.hpp>
#include <map>
#include <unordered_map>
#include <list>
#include <deque>
#include <array>
#include <deque>
#include <list>
#include <map>
#include <tuple>
#include <unordered_map>
#if TOML11_CPLUSPLUS_STANDARD_VERSION >= 201703L
#include <string_view>
#endif
#include <tuple>
using test_value_types = std::tuple<
toml::basic_value<toml::discard_comments>,
@ -823,4 +825,3 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(test_get_toml_offset_datetime, value_type, test_va
BOOST_TEST(tm.tm_sec == 0);
}
}

View File

@ -1,12 +1,14 @@
#include <toml.hpp>
#include "unit_test.hpp"
#include <toml.hpp>
#include <map>
#include <unordered_map>
#include <list>
#include <deque>
#include <array>
#include <deque>
#include <list>
#include <map>
#include <tuple>
#include <unordered_map>
#if TOML11_CPLUSPLUS_STANDARD_VERSION >= 201703L
#include <string_view>
#endif

View File

@ -1,12 +1,14 @@
#include <toml.hpp>
#include "unit_test.hpp"
#include <toml.hpp>
#include <map>
#include <unordered_map>
#include <list>
#include <deque>
#include <array>
#include <deque>
#include <list>
#include <map>
#include <tuple>
#include <unordered_map>
#if TOML11_CPLUSPLUS_STANDARD_VERSION >= 201703L
#include <string_view>
#endif

View File

@ -1,6 +1,7 @@
#include <toml.hpp>
#include "unit_test.hpp"
#include <toml.hpp>
#include <iostream>
// to check it successfully compiles. it does not check the formatted string.

View File

@ -1,12 +1,14 @@
#include <toml.hpp>
#include "unit_test.hpp"
#include <toml.hpp>
#include <map>
#include <unordered_map>
#include <list>
#include <deque>
#include <array>
#include <deque>
#include <list>
#include <map>
#include <tuple>
#include <unordered_map>
#if TOML11_CPLUSPLUS_STANDARD_VERSION >= 201703L
#include <string_view>
#endif

View File

@ -1,12 +1,14 @@
#include <toml.hpp>
#include "unit_test.hpp"
#include <toml.hpp>
#include <map>
#include <unordered_map>
#include <list>
#include <deque>
#include <array>
#include <deque>
#include <list>
#include <map>
#include <tuple>
#include <unordered_map>
#if TOML11_CPLUSPLUS_STANDARD_VERSION >= 201703L
#include <string_view>
#endif

View File

@ -1,6 +1,6 @@
#include "unit_test.hpp"
#include <toml/lexer.hpp>
#include "unit_test.hpp"
#include "test_lex_aux.hpp"
using namespace toml;

View File

@ -1,6 +1,6 @@
#include "unit_test.hpp"
#include <toml/lexer.hpp>
#include "unit_test.hpp"
#include "test_lex_aux.hpp"
using namespace toml;

View File

@ -1,9 +1,10 @@
#include "unit_test.hpp"
#include <toml/lexer.hpp>
#include <limits>
#include "unit_test.hpp"
#include "test_lex_aux.hpp"
#include <limits>
using namespace toml;
using namespace detail;

View File

@ -1,6 +1,6 @@
#include "unit_test.hpp"
#include <toml/lexer.hpp>
#include "unit_test.hpp"
#include "test_lex_aux.hpp"
using namespace toml;

View File

@ -1,6 +1,6 @@
#include "unit_test.hpp"
#include <toml/lexer.hpp>
#include "unit_test.hpp"
#include "test_lex_aux.hpp"
using namespace toml;

View File

@ -1,6 +1,6 @@
#include "unit_test.hpp"
#include <toml/lexer.hpp>
#include "unit_test.hpp"
#include "test_lex_aux.hpp"
using namespace toml;

View File

@ -1,6 +1,7 @@
#include <toml.hpp>
#include "unit_test.hpp"
#include <toml.hpp>
#include <map>
BOOST_AUTO_TEST_CASE(test_file_as_literal)

View File

@ -1,6 +1,6 @@
#include "unit_test.hpp"
#include <toml/parser.hpp>
#include "unit_test.hpp"
#include "test_parse_aux.hpp"
using namespace toml;

View File

@ -1,6 +1,6 @@
#include "unit_test.hpp"
#include <toml/parser.hpp>
#include "unit_test.hpp"
#include "test_parse_aux.hpp"
using namespace toml;

View File

@ -1,6 +1,6 @@
#include "unit_test.hpp"
#include <toml/parser.hpp>
#include "unit_test.hpp"
#include "test_parse_aux.hpp"
using namespace toml;

View File

@ -1,10 +1,11 @@
#include <toml.hpp>
#include "unit_test.hpp"
#include <toml.hpp>
#include <iostream>
#include <fstream>
#include <map>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
BOOST_AUTO_TEST_CASE(test_example)
{

View File

@ -1,9 +1,10 @@
#include "unit_test.hpp"
#include <toml/parser.hpp>
#include <cmath>
#include "unit_test.hpp"
#include "test_parse_aux.hpp"
#include <cmath>
using namespace toml;
using namespace detail;

View File

@ -1,6 +1,6 @@
#include "unit_test.hpp"
#include <toml/parser.hpp>
#include "unit_test.hpp"
#include "test_parse_aux.hpp"
using namespace toml;

View File

@ -1,6 +1,6 @@
#include "unit_test.hpp"
#include <toml/parser.hpp>
#include "unit_test.hpp"
#include "test_parse_aux.hpp"
using namespace toml;

View File

@ -1,6 +1,6 @@
#include "unit_test.hpp"
#include <toml/parser.hpp>
#include "unit_test.hpp"
#include "test_parse_aux.hpp"
using namespace toml;

View File

@ -1,6 +1,6 @@
#include "unit_test.hpp"
#include <toml/parser.hpp>
#include "unit_test.hpp"
#include "test_parse_aux.hpp"
using namespace toml;

View File

@ -1,7 +1,7 @@
#include "unit_test.hpp"
#include <toml/parser.hpp>
#include <toml/get.hpp>
#include <toml/parser.hpp>
#include "unit_test.hpp"
#include "test_parse_aux.hpp"
using namespace toml;

View File

@ -1,6 +1,6 @@
#include "unit_test.hpp"
#include <toml/parser.hpp>
#include "unit_test.hpp"
#include "test_parse_aux.hpp"
using namespace toml;

View File

@ -1,8 +1,9 @@
#include <toml.hpp>
#include "unit_test.hpp"
#include <toml.hpp>
#include <iostream>
#include <fstream>
#include <iostream>
BOOST_AUTO_TEST_CASE(test_hard_example_unicode)
{

View File

@ -1,7 +1,8 @@
#include <toml/result.hpp>
#include "unit_test.hpp"
#include <iostream>
#include <toml/result.hpp>
BOOST_AUTO_TEST_CASE(test_construct)
{

View File

@ -1,10 +1,11 @@
#include <toml.hpp>
#include "unit_test.hpp"
#include <toml.hpp>
#include <deque>
#include <map>
#include <iostream>
#include <fstream>
#include <iostream>
#include <map>
#include <sstream>
template<typename Comment,

View File

@ -1,7 +1,7 @@
#include "unit_test.hpp"
#include <toml.hpp>
#include "unit_test.hpp"
BOOST_AUTO_TEST_CASE(test_basic_string)
{
{

View File

@ -1,16 +1,16 @@
#include "unit_test.hpp"
#include <toml/types.hpp>
#include <list>
#include <forward_list>
#include <deque>
#include "unit_test.hpp"
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <string>
struct dummy_type{};

View File

@ -1,8 +1,9 @@
#include <toml/utility.hpp>
#include "unit_test.hpp"
#include <toml/utility.hpp>
#include <vector>
#include <array>
#include <vector>
BOOST_AUTO_TEST_CASE(test_try_reserve)
{

View File

@ -1,6 +1,7 @@
#include <toml.hpp>
#include "unit_test.hpp"
#include <toml.hpp>
#include <map>
#include <list>