diff --git a/tests/test_comments.cpp b/tests/test_comments.cpp index 23d4a68..a5765dc 100644 --- a/tests/test_comments.cpp +++ b/tests/test_comments.cpp @@ -1,9 +1,5 @@ #define BOOST_TEST_MODULE "test_comments" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" #include diff --git a/tests/test_datetime.cpp b/tests/test_datetime.cpp index 31bdcf7..1759c34 100644 --- a/tests/test_datetime.cpp +++ b/tests/test_datetime.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_datetime" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include BOOST_AUTO_TEST_CASE(test_local_date) diff --git a/tests/test_error_detection.cpp b/tests/test_error_detection.cpp index fbefcd4..3364d16 100644 --- a/tests/test_error_detection.cpp +++ b/tests/test_error_detection.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_error_detection" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include #include diff --git a/tests/test_expect.cpp b/tests/test_expect.cpp index d376ef1..131c1cc 100644 --- a/tests/test_expect.cpp +++ b/tests/test_expect.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_expect" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include #include diff --git a/tests/test_extended_conversions.cpp b/tests/test_extended_conversions.cpp index e84f013..28974d7 100644 --- a/tests/test_extended_conversions.cpp +++ b/tests/test_extended_conversions.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_extended_conversions" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include #include diff --git a/tests/test_find.cpp b/tests/test_find.cpp index cf58017..682ce87 100644 --- a/tests/test_find.cpp +++ b/tests/test_find.cpp @@ -1,10 +1,5 @@ #define BOOST_TEST_MODULE "test_find" - -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" #include #include diff --git a/tests/test_find_or.cpp b/tests/test_find_or.cpp index ed36e3a..8f1eb73 100644 --- a/tests/test_find_or.cpp +++ b/tests/test_find_or.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_find_or" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include #include diff --git a/tests/test_find_or_recursive.cpp b/tests/test_find_or_recursive.cpp index d31e8b6..22fcfb5 100644 --- a/tests/test_find_or_recursive.cpp +++ b/tests/test_find_or_recursive.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_find_or_recursive" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include #include diff --git a/tests/test_format_error.cpp b/tests/test_format_error.cpp index 1ae8db6..d347d85 100644 --- a/tests/test_format_error.cpp +++ b/tests/test_format_error.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_format_error" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include diff --git a/tests/test_get.cpp b/tests/test_get.cpp index 090eb07..eaae50e 100644 --- a/tests/test_get.cpp +++ b/tests/test_get.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_get" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include #include diff --git a/tests/test_get_or.cpp b/tests/test_get_or.cpp index 7aad273..68c4884 100644 --- a/tests/test_get_or.cpp +++ b/tests/test_get_or.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_get_or" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include #include diff --git a/tests/test_lex_boolean.cpp b/tests/test_lex_boolean.cpp index 933ab9d..b9f830c 100644 --- a/tests/test_lex_boolean.cpp +++ b/tests/test_lex_boolean.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_lex_boolean" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include "test_lex_aux.hpp" diff --git a/tests/test_lex_datetime.cpp b/tests/test_lex_datetime.cpp index 25e24bf..75e1c05 100644 --- a/tests/test_lex_datetime.cpp +++ b/tests/test_lex_datetime.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_lex_datetime" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include "test_lex_aux.hpp" diff --git a/tests/test_lex_floating.cpp b/tests/test_lex_floating.cpp index e14bdb3..1654874 100644 --- a/tests/test_lex_floating.cpp +++ b/tests/test_lex_floating.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_lex_floating" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include #include "test_lex_aux.hpp" diff --git a/tests/test_lex_integer.cpp b/tests/test_lex_integer.cpp index 1e8a31b..c3171c7 100644 --- a/tests/test_lex_integer.cpp +++ b/tests/test_lex_integer.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_lex_integer" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include "test_lex_aux.hpp" diff --git a/tests/test_lex_key_comment.cpp b/tests/test_lex_key_comment.cpp index 1aad90b..2315d86 100644 --- a/tests/test_lex_key_comment.cpp +++ b/tests/test_lex_key_comment.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "lex_key_comment_test" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include "test_lex_aux.hpp" diff --git a/tests/test_lex_string.cpp b/tests/test_lex_string.cpp index 880ee92..fb42ee3 100644 --- a/tests/test_lex_string.cpp +++ b/tests/test_lex_string.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_lex_string" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include "test_lex_aux.hpp" diff --git a/tests/test_literals.cpp b/tests/test_literals.cpp index 9d8ebea..e550845 100644 --- a/tests/test_literals.cpp +++ b/tests/test_literals.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_literals" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include diff --git a/tests/test_parse_array.cpp b/tests/test_parse_array.cpp index ee6a9ae..9943a98 100644 --- a/tests/test_parse_array.cpp +++ b/tests/test_parse_array.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "parse_array_test" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include "test_parse_aux.hpp" diff --git a/tests/test_parse_boolean.cpp b/tests/test_parse_boolean.cpp index 92c0042..f6cb26f 100644 --- a/tests/test_parse_boolean.cpp +++ b/tests/test_parse_boolean.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_parse_boolean" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include "test_parse_aux.hpp" diff --git a/tests/test_parse_datetime.cpp b/tests/test_parse_datetime.cpp index 5e86108..e4b2d23 100644 --- a/tests/test_parse_datetime.cpp +++ b/tests/test_parse_datetime.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "parse_datetime_test" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include "test_parse_aux.hpp" diff --git a/tests/test_parse_file.cpp b/tests/test_parse_file.cpp index 144168b..0bce6b7 100644 --- a/tests/test_parse_file.cpp +++ b/tests/test_parse_file.cpp @@ -1,26 +1,11 @@ #define BOOST_TEST_MODULE "test_parse_file" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include #include #include #include -#include - -static auto testinput(const std::string& basename) -> std::string -{ - const auto this_or_that = [](const char *const s, const char *const t) { return s ? s : t; }; - std::string directory = this_or_that(std::getenv("TOMLDIR"), "toml"); - if (!directory.empty() && directory.back() != '/') - { - directory.push_back('/'); - } - return directory.append("tests/").append(basename); -} BOOST_AUTO_TEST_CASE(test_example) { diff --git a/tests/test_parse_floating.cpp b/tests/test_parse_floating.cpp index 3fa2d03..dbe012d 100644 --- a/tests/test_parse_floating.cpp +++ b/tests/test_parse_floating.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "parse_floating_test" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include #include "test_parse_aux.hpp" diff --git a/tests/test_parse_inline_table.cpp b/tests/test_parse_inline_table.cpp index 9b3460a..dad3257 100644 --- a/tests/test_parse_inline_table.cpp +++ b/tests/test_parse_inline_table.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "parse_inline_table_test" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include "test_parse_aux.hpp" diff --git a/tests/test_parse_integer.cpp b/tests/test_parse_integer.cpp index ea203af..2d8e97f 100644 --- a/tests/test_parse_integer.cpp +++ b/tests/test_parse_integer.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "parse_integer_test" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include "test_parse_aux.hpp" diff --git a/tests/test_parse_key.cpp b/tests/test_parse_key.cpp index f7448a6..24e8f02 100644 --- a/tests/test_parse_key.cpp +++ b/tests/test_parse_key.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "parse_key_test" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include "test_parse_aux.hpp" diff --git a/tests/test_parse_string.cpp b/tests/test_parse_string.cpp index 4837460..63e734e 100644 --- a/tests/test_parse_string.cpp +++ b/tests/test_parse_string.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "parse_string_test" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include "test_parse_aux.hpp" diff --git a/tests/test_parse_table.cpp b/tests/test_parse_table.cpp index b6c9dd0..f5b8856 100644 --- a/tests/test_parse_table.cpp +++ b/tests/test_parse_table.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "parse_table_test" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include #include "test_parse_aux.hpp" diff --git a/tests/test_parse_table_key.cpp b/tests/test_parse_table_key.cpp index 1a7466b..18ba2ea 100644 --- a/tests/test_parse_table_key.cpp +++ b/tests/test_parse_table_key.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "parse_table_key_test" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include "test_parse_aux.hpp" diff --git a/tests/test_parse_unicode.cpp b/tests/test_parse_unicode.cpp index 7f07cb4..0f891e9 100644 --- a/tests/test_parse_unicode.cpp +++ b/tests/test_parse_unicode.cpp @@ -1,24 +1,9 @@ #define BOOST_TEST_MODULE "test_parse_unicode" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include #include -#include - -static auto testinput(const std::string& basename) -> std::string -{ - const auto this_or_that = [](const char *const s, const char *const t) { return s ? s : t; }; - std::string directory = this_or_that(std::getenv("TOMLDIR"), "toml"); - if (!directory.empty() && directory.back() != '/') - { - directory.push_back('/'); - } - return directory.append("tests/").append(basename); -} BOOST_AUTO_TEST_CASE(test_hard_example_unicode) { diff --git a/tests/test_result.cpp b/tests/test_result.cpp index 9a70041..47332d2 100644 --- a/tests/test_result.cpp +++ b/tests/test_result.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_result" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include diff --git a/tests/test_serialize_file.cpp b/tests/test_serialize_file.cpp index 305ca0d..d26ce69 100644 --- a/tests/test_serialize_file.cpp +++ b/tests/test_serialize_file.cpp @@ -1,11 +1,7 @@ #define BOOST_TEST_MODULE "test_serialize_file" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include -#include #include #include #include @@ -45,17 +41,6 @@ bool has_comment_inside(const toml::basic_value& v) return true; } -static auto testinput(const std::string& basename) -> std::string -{ - const auto this_or_that = [](const char *const s, const char *const t) { return s ? s : t; }; - std::string directory = this_or_that(std::getenv("TOMLDIR"), "toml"); - if (!directory.empty() && directory.back() != '/') - { - directory.push_back('/'); - } - return directory.append("tests/").append(basename); -} - BOOST_AUTO_TEST_CASE(test_example) { const auto data = toml::parse(testinput("example.toml")); diff --git a/tests/test_string.cpp b/tests/test_string.cpp index a9fec2a..2ed2c17 100644 --- a/tests/test_string.cpp +++ b/tests/test_string.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_string" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include BOOST_AUTO_TEST_CASE(test_basic_string) diff --git a/tests/test_traits.cpp b/tests/test_traits.cpp index f6f5bc1..ce73d3d 100644 --- a/tests/test_traits.cpp +++ b/tests/test_traits.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_traits" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include diff --git a/tests/test_utility.cpp b/tests/test_utility.cpp index 05981c2..37302cb 100644 --- a/tests/test_utility.cpp +++ b/tests/test_utility.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_acceptor" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include #include diff --git a/tests/test_value.cpp b/tests/test_value.cpp index b25731e..29781ad 100644 --- a/tests/test_value.cpp +++ b/tests/test_value.cpp @@ -1,9 +1,6 @@ #define BOOST_TEST_MODULE "test_value" -#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST -#include -#else -#include -#endif +#include "unit_test.hpp" + #include #include #include diff --git a/tests/unit_test.hpp b/tests/unit_test.hpp new file mode 100644 index 0000000..5999f57 --- /dev/null +++ b/tests/unit_test.hpp @@ -0,0 +1,23 @@ +#ifndef BOOST_TEST_MODULE +# error "Please #define BOOST_TEST_MODULE before you #include " +#endif + +#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST +# include +#else +# include +#endif + +#include +#include + +static inline auto testinput(const std::string& basename) -> std::string +{ + const auto this_or_that = [](const char *const s, const char *const t) { return s ? s : t; }; + std::string directory = this_or_that(std::getenv("TOMLDIR"), "toml"); + if (!directory.empty() && directory.back() != '/') + { + directory.push_back('/'); + } + return directory.append("tests/").append(basename); +}