mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 00:38:08 +08:00
test: add test cases of toml::get_or(value&&, T&&)
This commit is contained in:
@@ -126,6 +126,55 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(test_get_or_exact, value_type, test_value_types)
|
||||
}
|
||||
#undef TOML11_TEST_GET_OR_EXACT
|
||||
|
||||
#define TOML11_TEST_GET_OR_MOVE_EXACT(toml_type, init_expr, opt_expr)\
|
||||
{ \
|
||||
using namespace test; \
|
||||
const toml::toml_type init init_expr ; \
|
||||
toml::toml_type opt opt_expr ; \
|
||||
value_type v(init); \
|
||||
BOOST_TEST(init != opt); \
|
||||
const auto opt_ = toml::get_or(std::move(v), std::move(opt));\
|
||||
BOOST_TEST(init == opt_); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE(test_get_or_move, value_type, test_value_types)
|
||||
{
|
||||
TOML11_TEST_GET_OR_MOVE_EXACT(boolean, ( true), (false))
|
||||
TOML11_TEST_GET_OR_MOVE_EXACT(integer, ( 42), ( 54))
|
||||
TOML11_TEST_GET_OR_MOVE_EXACT(floating, ( 3.14), ( 2.71))
|
||||
TOML11_TEST_GET_OR_MOVE_EXACT(string, ("foo"), ("bar"))
|
||||
TOML11_TEST_GET_OR_MOVE_EXACT(local_time, (12, 30, 45), (6, 0, 30))
|
||||
TOML11_TEST_GET_OR_MOVE_EXACT(local_date, (2019, toml::month_t::Apr, 1),
|
||||
(1999, toml::month_t::Jan, 2))
|
||||
TOML11_TEST_GET_OR_MOVE_EXACT(local_datetime,
|
||||
(toml::local_date(2019, toml::month_t::Apr, 1), toml::local_time(12, 30, 45)),
|
||||
(toml::local_date(1999, toml::month_t::Jan, 2), toml::local_time( 6, 0, 30))
|
||||
)
|
||||
TOML11_TEST_GET_OR_MOVE_EXACT(offset_datetime,
|
||||
(toml::local_date(2019, toml::month_t::Apr, 1), toml::local_time(12, 30, 45), toml::time_offset( 9, 0)),
|
||||
(toml::local_date(1999, toml::month_t::Jan, 2), toml::local_time( 6, 0, 30), toml::time_offset(-3, 0))
|
||||
)
|
||||
{
|
||||
const typename value_type::array_type init{1,2,3,4,5};
|
||||
typename value_type::array_type opt {6,7,8,9,10};
|
||||
value_type v(init);
|
||||
BOOST_TEST(init != opt);
|
||||
const auto opt_ = toml::get_or(std::move(v), std::move(opt));
|
||||
BOOST_TEST(init == opt_);
|
||||
}
|
||||
{
|
||||
const typename value_type::table_type init{{"key1", 42}, {"key2", "foo"}};
|
||||
typename value_type::table_type opt {{"key1", 54}, {"key2", "bar"}};
|
||||
value_type v(init);
|
||||
BOOST_TEST(init != opt);
|
||||
const auto opt_ = toml::get_or(std::move(v), std::move(opt));
|
||||
BOOST_TEST(init == opt_);
|
||||
}
|
||||
}
|
||||
#undef TOML11_TEST_GET_OR_MOVE_EXACT
|
||||
|
||||
|
||||
#define TOML11_TEST_GET_OR_MODIFY(toml_type, init_expr, opt_expr)\
|
||||
{ \
|
||||
using namespace test; \
|
||||
|
Reference in New Issue
Block a user