2018-12-11 14:38:57 +00:00
|
|
|
#define BOOST_TEST_MODULE "parse_inline_table_test"
|
|
|
|
#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/parser.hpp>
|
|
|
|
#include "test_parse_aux.hpp"
|
|
|
|
|
|
|
|
using namespace toml;
|
|
|
|
using namespace detail;
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(test_inline_table)
|
|
|
|
{
|
2019-06-03 13:01:16 +00:00
|
|
|
TOML11_TEST_PARSE_EQUAL(parse_inline_table<toml::value>, "{}", table());
|
2018-12-11 14:38:57 +00:00
|
|
|
{
|
|
|
|
table t;
|
|
|
|
t["foo"] = toml::value(42);
|
|
|
|
t["bar"] = toml::value("baz");
|
2019-06-03 13:01:16 +00:00
|
|
|
TOML11_TEST_PARSE_EQUAL(parse_inline_table<toml::value>, "{foo = 42, bar = \"baz\"}", t);
|
2018-12-11 14:38:57 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
table t;
|
|
|
|
table t_sub;
|
|
|
|
t_sub["name"] = toml::value("pug");
|
|
|
|
t["type"] = toml::value(t_sub);
|
2019-06-03 13:01:16 +00:00
|
|
|
TOML11_TEST_PARSE_EQUAL(parse_inline_table<toml::value>, "{type.name = \"pug\"}", t);
|
2018-12-11 14:38:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(test_inline_table_value)
|
|
|
|
{
|
2019-06-03 13:01:16 +00:00
|
|
|
TOML11_TEST_PARSE_EQUAL_VALUE(parse_value<toml::value>, "{}", value(table()));
|
2018-12-11 14:38:57 +00:00
|
|
|
{
|
|
|
|
table t;
|
|
|
|
t["foo"] = toml::value(42);
|
|
|
|
t["bar"] = toml::value("baz");
|
2019-06-03 13:01:16 +00:00
|
|
|
TOML11_TEST_PARSE_EQUAL_VALUE(parse_value<toml::value>, "{foo = 42, bar = \"baz\"}", value(t));
|
2018-12-11 14:38:57 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
table t;
|
|
|
|
table t_sub;
|
|
|
|
t_sub["name"] = toml::value("pug");
|
|
|
|
t["type"] = toml::value(t_sub);
|
2019-06-03 13:01:16 +00:00
|
|
|
TOML11_TEST_PARSE_EQUAL_VALUE(parse_value<toml::value>, "{type.name = \"pug\"}", value(t));
|
2018-12-11 14:38:57 +00:00
|
|
|
}
|
|
|
|
}
|