mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:58:09 +08:00

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.
29 lines
839 B
C++
29 lines
839 B
C++
#define BOOST_TEST_MODULE "test_lex_boolean"
|
|
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
|
#include <boost/test/unit_test.hpp>
|
|
#else
|
|
#define BOOST_TEST_NO_LIB
|
|
#include <boost/test/included/unit_test.hpp>
|
|
#endif
|
|
#include <toml/lexer.hpp>
|
|
#include "test_lex_aux.hpp"
|
|
|
|
using namespace toml;
|
|
using namespace detail;
|
|
|
|
BOOST_AUTO_TEST_CASE(test_correct)
|
|
{
|
|
TOML11_TEST_LEX_ACCEPT(lex_boolean, "true", "true");
|
|
TOML11_TEST_LEX_ACCEPT(lex_boolean, "false", "false");
|
|
TOML11_TEST_LEX_ACCEPT(lex_boolean, "true # trailing", "true");
|
|
TOML11_TEST_LEX_ACCEPT(lex_boolean, "false # trailing", "false");
|
|
}
|
|
|
|
BOOST_AUTO_TEST_CASE(test_invalid)
|
|
{
|
|
TOML11_TEST_LEX_REJECT(lex_boolean, "TRUE");
|
|
TOML11_TEST_LEX_REJECT(lex_boolean, "FALSE");
|
|
TOML11_TEST_LEX_REJECT(lex_boolean, "True");
|
|
TOML11_TEST_LEX_REJECT(lex_boolean, "False");
|
|
}
|