mirror of
https://github.com/ToruNiina/toml11.git
synced 2024-11-09 22:30:07 +00:00
fe471bcbe9
The conditional inclusion of either the library or the header-only version of the Boost.Test header wasn't tremendously useful in practice because the tests/CMakeLists.txt file would unconditionally add compile definitions to basically fore dynamic linking. This patch adds feature detection to the tests/CMakeLists.txt file to determine whether to use dynamic linking, static linking or the header-only version (in that order of preference, for best performance). The automatic detection could be overridden if needed by defining the TOML11_WITH_BOOST_TEST_{HEADER,STATIC,DYNAMIC} variables on the CMake command line. While we are at it, instead of having a conditional #define BOOST_TEST_NO_LIB in each unit test file, handle this once in the CMakeLists.txt file.
62 lines
1.9 KiB
C++
62 lines
1.9 KiB
C++
#define BOOST_TEST_MODULE "test_lex_datetime"
|
|
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
|
#include <boost/test/unit_test.hpp>
|
|
#else
|
|
#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");
|
|
}
|