Files
toml11/tests/test_lex_datetime.cpp
Moritz Klammler 5312b8eb0e 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.
2022-09-29 17:59:28 +02:00

63 lines
2.0 KiB
C++

#define BOOST_TEST_MODULE "test_lex_datetime"
#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_offset_datetime)
{
TOML11_TEST_LEX_ACCEPT(lex_offset_date_time,
"1979-05-27T07:32:00Z",
"1979-05-27T07:32:00Z");
TOML11_TEST_LEX_ACCEPT(lex_offset_date_time,
"1979-05-27T07:32:00-07:00",
"1979-05-27T07:32:00-07:00");
TOML11_TEST_LEX_ACCEPT(lex_offset_date_time,
"1979-05-27T07:32:00.999999-07:00",
"1979-05-27T07:32:00.999999-07:00");
TOML11_TEST_LEX_ACCEPT(lex_offset_date_time,
"1979-05-27 07:32:00Z",
"1979-05-27 07:32:00Z");
TOML11_TEST_LEX_ACCEPT(lex_offset_date_time,
"1979-05-27 07:32:00-07:00",
"1979-05-27 07:32:00-07:00");
TOML11_TEST_LEX_ACCEPT(lex_offset_date_time,
"1979-05-27 07:32:00.999999-07:00",
"1979-05-27 07:32:00.999999-07:00");
}
BOOST_AUTO_TEST_CASE(test_local_datetime)
{
TOML11_TEST_LEX_ACCEPT(lex_local_date_time,
"1979-05-27T07:32:00",
"1979-05-27T07:32:00");
TOML11_TEST_LEX_ACCEPT(lex_local_date_time,
"1979-05-27T07:32:00.999999",
"1979-05-27T07:32:00.999999");
TOML11_TEST_LEX_ACCEPT(lex_local_date_time,
"1979-05-27 07:32:00",
"1979-05-27 07:32:00");
TOML11_TEST_LEX_ACCEPT(lex_local_date_time,
"1979-05-27 07:32:00.999999",
"1979-05-27 07:32:00.999999");
}
BOOST_AUTO_TEST_CASE(test_local_date)
{
TOML11_TEST_LEX_ACCEPT(lex_local_date, "1979-05-27", "1979-05-27");
}
BOOST_AUTO_TEST_CASE(test_local_time)
{
TOML11_TEST_LEX_ACCEPT(lex_local_time, "07:32:00", "07:32:00");
TOML11_TEST_LEX_ACCEPT(lex_local_time, "07:32:00.999999", "07:32:00.999999");
}