From 5312b8eb0e70060e181c464f2541dd87ca76760f Mon Sep 17 00:00:00 2001 From: Moritz Klammler Date: Thu, 15 Sep 2022 19:54:27 +0200 Subject: [PATCH] Honor UNITTEST_FRAMEWORK_LIBRARY_EXIST in all unit test files Most unit test files checked UNITTEST_FRAMEWORK_LIBRARY_EXIST and adapted themselves accordingly to either use the header-only version or link with the library. Alas, eight files didn't so the project couldn't really be tested with the header-only version of that Boost library. This patch adds the missing pre-processor logic to the files that were missing it. The style of using no indentation after the '#' was followed from the existing unit test files. Some other files in this repository do indent their pre-processor logic, though. Since replicating the conditional in every file is kind of verbose, tedious and, apparently, easily forgotten, I'm wondering whether isolating that logic into a tiny little auxiliary header and then unconditionally including that one in each unit test file would be a good idea, though. --- tests/test_lex_boolean.cpp | 5 +++++ tests/test_lex_datetime.cpp | 5 +++++ tests/test_lex_floating.cpp | 5 +++++ tests/test_lex_integer.cpp | 5 +++++ tests/test_lex_key_comment.cpp | 5 +++++ tests/test_lex_string.cpp | 5 +++++ tests/test_result.cpp | 5 +++++ tests/test_string.cpp | 5 +++++ 8 files changed, 40 insertions(+) diff --git a/tests/test_lex_boolean.cpp b/tests/test_lex_boolean.cpp index c2e43a8..c872de3 100644 --- a/tests/test_lex_boolean.cpp +++ b/tests/test_lex_boolean.cpp @@ -1,5 +1,10 @@ #define BOOST_TEST_MODULE "test_lex_boolean" +#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST #include +#else +#define BOOST_TEST_NO_LIB +#include +#endif #include #include "test_lex_aux.hpp" diff --git a/tests/test_lex_datetime.cpp b/tests/test_lex_datetime.cpp index a790eeb..fa9b4c3 100644 --- a/tests/test_lex_datetime.cpp +++ b/tests/test_lex_datetime.cpp @@ -1,5 +1,10 @@ #define BOOST_TEST_MODULE "test_lex_datetime" +#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST #include +#else +#define BOOST_TEST_NO_LIB +#include +#endif #include #include "test_lex_aux.hpp" diff --git a/tests/test_lex_floating.cpp b/tests/test_lex_floating.cpp index 9c5c809..882cd81 100644 --- a/tests/test_lex_floating.cpp +++ b/tests/test_lex_floating.cpp @@ -1,5 +1,10 @@ #define BOOST_TEST_MODULE "test_lex_floating" +#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST #include +#else +#define BOOST_TEST_NO_LIB +#include +#endif #include #include #include "test_lex_aux.hpp" diff --git a/tests/test_lex_integer.cpp b/tests/test_lex_integer.cpp index bb6dbb7..f16c81c 100644 --- a/tests/test_lex_integer.cpp +++ b/tests/test_lex_integer.cpp @@ -1,5 +1,10 @@ #define BOOST_TEST_MODULE "test_lex_integer" +#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST #include +#else +#define BOOST_TEST_NO_LIB +#include +#endif #include #include "test_lex_aux.hpp" diff --git a/tests/test_lex_key_comment.cpp b/tests/test_lex_key_comment.cpp index 0921bd6..ba5c37c 100644 --- a/tests/test_lex_key_comment.cpp +++ b/tests/test_lex_key_comment.cpp @@ -1,5 +1,10 @@ #define BOOST_TEST_MODULE "lex_key_comment_test" +#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST #include +#else +#define BOOST_TEST_NO_LIB +#include +#endif #include #include "test_lex_aux.hpp" diff --git a/tests/test_lex_string.cpp b/tests/test_lex_string.cpp index 643ab31..0671358 100644 --- a/tests/test_lex_string.cpp +++ b/tests/test_lex_string.cpp @@ -1,5 +1,10 @@ #define BOOST_TEST_MODULE "test_lex_string" +#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST #include +#else +#define BOOST_TEST_NO_LIB +#include +#endif #include #include "test_lex_aux.hpp" diff --git a/tests/test_result.cpp b/tests/test_result.cpp index d693bd6..36368a2 100644 --- a/tests/test_result.cpp +++ b/tests/test_result.cpp @@ -1,5 +1,10 @@ #define BOOST_TEST_MODULE "test_result" +#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST #include +#else +#define BOOST_TEST_NO_LIB +#include +#endif #include #include diff --git a/tests/test_string.cpp b/tests/test_string.cpp index 444fc63..473c611 100644 --- a/tests/test_string.cpp +++ b/tests/test_string.cpp @@ -1,5 +1,10 @@ #define BOOST_TEST_MODULE "test_string" +#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST #include +#else +#define BOOST_TEST_NO_LIB +#include +#endif #include BOOST_AUTO_TEST_CASE(test_basic_string)