mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:58:09 +08:00
test: add basic_value type to serialization tests
This commit is contained in:
@@ -15,67 +15,66 @@ BOOST_AUTO_TEST_CASE(test_example)
|
||||
{
|
||||
const auto data = toml::parse("toml/tests/example.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "title"), "TOML Example");
|
||||
BOOST_TEST(toml::find<std::string>(data, "title") == "TOML Example");
|
||||
const auto& owner = toml::find(data, "owner");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(owner, "name"), "Tom Preston-Werner");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(owner, "organization"), "GitHub");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(owner, "bio"),
|
||||
BOOST_TEST(toml::find<std::string>(owner, "name") == "Tom Preston-Werner");
|
||||
BOOST_TEST(toml::find<std::string>(owner, "organization") == "GitHub");
|
||||
BOOST_TEST(toml::find<std::string>(owner, "bio") ==
|
||||
"GitHub Cofounder & CEO\nLikes tater tots and beer.");
|
||||
BOOST_CHECK_EQUAL(toml::find<toml::offset_datetime>(owner, "dob"),
|
||||
BOOST_TEST(toml::find<toml::offset_datetime>(owner, "dob") ==
|
||||
toml::offset_datetime(toml::local_date(1979, toml::month_t::May, 27),
|
||||
toml::local_time(7, 32, 0), toml::time_offset(0, 0)));
|
||||
}
|
||||
|
||||
const auto& database = toml::find(data, "database");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(database, "server"), "192.168.1.1");
|
||||
BOOST_TEST(toml::find<std::string>(database, "server") == "192.168.1.1");
|
||||
const std::vector<int> expected_ports{8001, 8001, 8002};
|
||||
BOOST_CHECK(toml::find<std::vector<int>>(database, "ports") == expected_ports);
|
||||
BOOST_CHECK_EQUAL(toml::find<int >(database, "connection_max"), 5000);
|
||||
BOOST_CHECK_EQUAL(toml::find<bool>(database, "enabled"), true);
|
||||
const bool result = toml::find<std::vector<int>>(database, "ports") == expected_ports;
|
||||
BOOST_TEST(result);
|
||||
BOOST_TEST(toml::find<int >(database, "connection_max") == 5000);
|
||||
BOOST_TEST(toml::find<bool>(database, "enabled") == true);
|
||||
}
|
||||
|
||||
const auto& servers = toml::find(data, "servers");
|
||||
{
|
||||
toml::table alpha = toml::find<toml::table>(servers, "alpha");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(alpha.at("ip")), "10.0.0.1");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(alpha.at("dc")), "eqdc10");
|
||||
BOOST_TEST(toml::get<std::string>(alpha.at("ip")) == "10.0.0.1");
|
||||
BOOST_TEST(toml::get<std::string>(alpha.at("dc")) == "eqdc10");
|
||||
|
||||
toml::table beta = toml::find<toml::table>(servers, "beta");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(beta.at("ip")), "10.0.0.2");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(beta.at("dc")), "eqdc10");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(beta.at("country")), "\xE4\xB8\xAD\xE5\x9B\xBD");
|
||||
BOOST_TEST(toml::get<std::string>(beta.at("ip")) == "10.0.0.2");
|
||||
BOOST_TEST(toml::get<std::string>(beta.at("dc")) == "eqdc10");
|
||||
BOOST_TEST(toml::get<std::string>(beta.at("country")) == "\xE4\xB8\xAD\xE5\x9B\xBD");
|
||||
}
|
||||
|
||||
const auto& clients = toml::find(data, "clients");
|
||||
{
|
||||
toml::array clients_data = toml::find<toml::array>(clients, "data");
|
||||
|
||||
std::vector<std::string> expected_name{"gamma", "delta"};
|
||||
BOOST_CHECK(toml::get<std::vector<std::string>>(clients_data.at(0)) ==
|
||||
expected_name);
|
||||
const bool result1 = toml::get<std::vector<std::string>>(clients_data.at(0)) == expected_name;
|
||||
BOOST_TEST(reuslt1);
|
||||
|
||||
std::vector<int> expected_number{1, 2};
|
||||
BOOST_CHECK(toml::get<std::vector<int>>(clients_data.at(1)) ==
|
||||
expected_number);
|
||||
const bool result2 = toml::get<std::vector<int>>(clients_data.at(1)) == expected_number;
|
||||
BOOST_TEST(reuslt2);
|
||||
|
||||
std::vector<std::string> expected_hosts{"alpha", "omega"};
|
||||
BOOST_CHECK(toml::find<std::vector<std::string>>(clients, "hosts") ==
|
||||
expected_hosts);
|
||||
const bool result3 = toml::find<std::vector<std::string>>(clients, "hosts") == expected_hosts;
|
||||
BOOST_TEST(reuslt3);
|
||||
}
|
||||
|
||||
std::vector<toml::table> products =
|
||||
toml::find<std::vector<toml::table>>(data, "products");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(products.at(0).at("name")),
|
||||
"Hammer");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::int64_t>(products.at(0).at("sku")),
|
||||
738594937);
|
||||
BOOST_TEST(toml::get<std::string>(products.at(0).at("name")) == "Hammer");
|
||||
BOOST_TEST(toml::get<std::int64_t>(products.at(0).at("sku")) == 738594937);
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(products.at(1).at("name")),
|
||||
"Nail");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::int64_t>(products.at(1).at("sku")),
|
||||
284758393);
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(products.at(1).at("color")),
|
||||
"gray");
|
||||
BOOST_TEST(toml::get<std::string>(products.at(1).at("name")) == "Nail");
|
||||
BOOST_TEST(toml::get<std::int64_t>(products.at(1).at("sku")) == 284758393);
|
||||
BOOST_TEST(toml::get<std::string>(products.at(1).at("color")) == "gray");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,66 +83,69 @@ BOOST_AUTO_TEST_CASE(test_example_stream)
|
||||
std::ifstream ifs("toml/tests/example.toml");
|
||||
const auto data = toml::parse(ifs);
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "title"), "TOML Example");
|
||||
BOOST_TEST(toml::find<std::string>(data, "title") == "TOML Example");
|
||||
const auto& owner = toml::find(data, "owner");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(owner, "name"), "Tom Preston-Werner");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(owner, "organization"), "GitHub");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(owner, "bio"),
|
||||
BOOST_TEST(toml::find<std::string>(owner, "name") == "Tom Preston-Werner");
|
||||
BOOST_TEST(toml::find<std::string>(owner, "organization") == "GitHub");
|
||||
BOOST_TEST(toml::find<std::string>(owner, "bio") ==
|
||||
"GitHub Cofounder & CEO\nLikes tater tots and beer.");
|
||||
BOOST_CHECK_EQUAL(toml::find<toml::offset_datetime>(owner, "dob"),
|
||||
BOOST_TEST(toml::find<toml::offset_datetime>(owner, "dob") ==
|
||||
toml::offset_datetime(toml::local_date(1979, toml::month_t::May, 27),
|
||||
toml::local_time(7, 32, 0), toml::time_offset(0, 0)));
|
||||
}
|
||||
|
||||
const auto& database = toml::find(data, "database");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(database, "server"), "192.168.1.1");
|
||||
BOOST_TEST(toml::find<std::string>(database, "server") == "192.168.1.1");
|
||||
const std::vector<int> expected_ports{8001, 8001, 8002};
|
||||
BOOST_CHECK(toml::find<std::vector<int>>(database, "ports") == expected_ports);
|
||||
BOOST_CHECK_EQUAL(toml::find<int >(database, "connection_max"), 5000);
|
||||
BOOST_CHECK_EQUAL(toml::find<bool>(database, "enabled"), true);
|
||||
const bool result = (toml::find<std::vector<int>>(database, "ports") == expected_ports);
|
||||
BOOST_TEST(result);
|
||||
BOOST_TEST(toml::find<int >(database, "connection_max") == 5000);
|
||||
BOOST_TEST(toml::find<bool>(database, "enabled") == true);
|
||||
}
|
||||
|
||||
const auto& servers = toml::find(data, "servers");
|
||||
{
|
||||
toml::table alpha = toml::find<toml::table>(servers, "alpha");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(alpha.at("ip")), "10.0.0.1");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(alpha.at("dc")), "eqdc10");
|
||||
BOOST_TEST(toml::get<std::string>(alpha.at("ip")) == "10.0.0.1");
|
||||
BOOST_TEST(toml::get<std::string>(alpha.at("dc")) == "eqdc10");
|
||||
|
||||
toml::table beta = toml::find<toml::table>(servers, "beta");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(beta.at("ip")), "10.0.0.2");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(beta.at("dc")), "eqdc10");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(beta.at("country")), "\xE4\xB8\xAD\xE5\x9B\xBD");
|
||||
BOOST_TEST(toml::get<std::string>(beta.at("ip")) == "10.0.0.2");
|
||||
BOOST_TEST(toml::get<std::string>(beta.at("dc")) == "eqdc10");
|
||||
BOOST_TEST(toml::get<std::string>(beta.at("country")) == "\xE4\xB8\xAD\xE5\x9B\xBD");
|
||||
}
|
||||
|
||||
const auto& clients = toml::find(data, "clients");
|
||||
{
|
||||
toml::array clients_data = toml::find<toml::array>(clients, "data");
|
||||
std::vector<std::string> expected_name{"gamma", "delta"};
|
||||
BOOST_CHECK(toml::get<std::vector<std::string>>(clients_data.at(0)) ==
|
||||
expected_name);
|
||||
const bool result1 = toml::get<std::vector<std::string>>(clients_data.at(0)) == expected_name;
|
||||
BOOST_TEST(reuslt1);
|
||||
|
||||
std::vector<int> expected_number{1, 2};
|
||||
BOOST_CHECK(toml::get<std::vector<int>>(clients_data.at(1)) ==
|
||||
expected_number);
|
||||
const bool result2 = toml::get<std::vector<int>>(clients_data.at(1)) == expected_number;
|
||||
BOOST_TEST(reuslt2);
|
||||
|
||||
std::vector<std::string> expected_hosts{"alpha", "omega"};
|
||||
BOOST_CHECK(toml::find<std::vector<std::string>>(clients, "hosts") ==
|
||||
expected_hosts);
|
||||
const bool result3 = toml::find<std::vector<std::string>>(clients, "hosts") == expected_hosts;
|
||||
BOOST_TEST(reuslt3);
|
||||
}
|
||||
|
||||
std::vector<toml::table> products =
|
||||
toml::find<std::vector<toml::table>>(data, "products");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(products.at(0).at("name")),
|
||||
BOOST_TEST(toml::get<std::string>(products.at(0).at("name")) ==
|
||||
"Hammer");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::int64_t>(products.at(0).at("sku")),
|
||||
BOOST_TEST(toml::get<std::int64_t>(products.at(0).at("sku")) ==
|
||||
738594937);
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(products.at(1).at("name")),
|
||||
BOOST_TEST(toml::get<std::string>(products.at(1).at("name")) ==
|
||||
"Nail");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::int64_t>(products.at(1).at("sku")),
|
||||
BOOST_TEST(toml::get<std::int64_t>(products.at(1).at("sku")) ==
|
||||
284758393);
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(products.at(1).at("color")),
|
||||
BOOST_TEST(toml::get<std::string>(products.at(1).at("color")) ==
|
||||
"gray");
|
||||
}
|
||||
}
|
||||
@@ -152,17 +154,17 @@ BOOST_AUTO_TEST_CASE(test_fruit)
|
||||
{
|
||||
const auto data = toml::parse("toml/tests/fruit.toml");
|
||||
const auto blah = toml::find<toml::array>(toml::find(data, "fruit"), "blah");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(blah.at(0), "name"), "apple");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(blah.at(1), "name"), "banana");
|
||||
BOOST_TEST(toml::find<std::string>(blah.at(0), "name") == "apple");
|
||||
BOOST_TEST(toml::find<std::string>(blah.at(1), "name") == "banana");
|
||||
{
|
||||
const auto physical = toml::find(blah.at(0), "physical");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(physical, "color"), "red");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(physical, "shape"), "round");
|
||||
BOOST_TEST(toml::find<std::string>(physical, "color") == "red");
|
||||
BOOST_TEST(toml::find<std::string>(physical, "shape") == "round");
|
||||
}
|
||||
{
|
||||
const auto physical = toml::find(blah.at(1), "physical");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(physical, "color"), "yellow");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(physical, "shape"), "bent");
|
||||
BOOST_TEST(toml::find<std::string>(physical, "color") == "yellow");
|
||||
BOOST_TEST(toml::find<std::string>(physical, "shape") == "bent");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +172,7 @@ BOOST_AUTO_TEST_CASE(test_hard_example)
|
||||
{
|
||||
const auto data = toml::parse("toml/tests/hard_example.toml");
|
||||
const auto the = toml::find(data, "the");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(the, "test_string"),
|
||||
BOOST_TEST(toml::find<std::string>(the, "test_string") ==
|
||||
"You'll hate me after this - #");
|
||||
|
||||
const auto hard = toml::find(the, "hard");
|
||||
@@ -181,13 +183,13 @@ BOOST_AUTO_TEST_CASE(test_hard_example)
|
||||
"Test #11 ]proved that", "Experiment #9 was a success"};
|
||||
BOOST_CHECK(toml::find<std::vector<std::string>>(hard, "test_array2") ==
|
||||
expected_the_hard_test_array2);
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(hard, "another_test_string"),
|
||||
BOOST_TEST(toml::find<std::string>(hard, "another_test_string") ==
|
||||
" Same thing, but with a string #");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(hard, "harder_test_string"),
|
||||
BOOST_TEST(toml::find<std::string>(hard, "harder_test_string") ==
|
||||
" And when \"'s are in the string, along with # \"");
|
||||
|
||||
const auto bit = toml::find(hard, "bit#");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(bit, "what?"),
|
||||
BOOST_TEST(toml::find<std::string>(bit, "what?") ==
|
||||
"You don't think some user won't do that?");
|
||||
const std::vector<std::string> expected_multi_line_array{"]"};
|
||||
BOOST_CHECK(toml::find<std::vector<std::string>>(bit, "multi_line_array") ==
|
||||
@@ -197,7 +199,7 @@ BOOST_AUTO_TEST_CASE(test_hard_example_comment)
|
||||
{
|
||||
const auto data = toml::parse<toml::preserve_comments>("toml/tests/hard_example.toml");
|
||||
const auto the = toml::find(data, "the");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(the, "test_string"),
|
||||
BOOST_TEST(toml::find<std::string>(the, "test_string") ==
|
||||
"You'll hate me after this - #");
|
||||
|
||||
const auto hard = toml::find(the, "hard");
|
||||
@@ -208,13 +210,13 @@ BOOST_AUTO_TEST_CASE(test_hard_example_comment)
|
||||
"Test #11 ]proved that", "Experiment #9 was a success"};
|
||||
BOOST_CHECK(toml::find<std::vector<std::string>>(hard, "test_array2") ==
|
||||
expected_the_hard_test_array2);
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(hard, "another_test_string"),
|
||||
BOOST_TEST(toml::find<std::string>(hard, "another_test_string") ==
|
||||
" Same thing, but with a string #");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(hard, "harder_test_string"),
|
||||
BOOST_TEST(toml::find<std::string>(hard, "harder_test_string") ==
|
||||
" And when \"'s are in the string, along with # \"");
|
||||
|
||||
const auto bit = toml::find(hard, "bit#");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(bit, "what?"),
|
||||
BOOST_TEST(toml::find<std::string>(bit, "what?") ==
|
||||
"You don't think some user won't do that?");
|
||||
const std::vector<std::string> expected_multi_line_array{"]"};
|
||||
BOOST_CHECK(toml::find<std::vector<std::string>>(bit, "multi_line_array") ==
|
||||
@@ -226,49 +228,49 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_comment)
|
||||
{
|
||||
const auto data = toml::parse<toml::preserve_comments>("toml/tests/example.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "title"), "TOML Example");
|
||||
BOOST_TEST(toml::find<std::string>(data, "title") == "TOML Example");
|
||||
const auto& owner = toml::find(data, "owner");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(owner, "name"), "Tom Preston-Werner");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(owner, "organization"), "GitHub");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(owner, "bio"),
|
||||
BOOST_TEST(toml::find<std::string>(owner, "name") == "Tom Preston-Werner");
|
||||
BOOST_TEST(toml::find<std::string>(owner, "organization") == "GitHub");
|
||||
BOOST_TEST(toml::find<std::string>(owner, "bio") ==
|
||||
"GitHub Cofounder & CEO\nLikes tater tots and beer.");
|
||||
BOOST_CHECK_EQUAL(toml::find<toml::offset_datetime>(owner, "dob"),
|
||||
BOOST_TEST(toml::find<toml::offset_datetime>(owner, "dob") ==
|
||||
toml::offset_datetime(toml::local_date(1979, toml::month_t::May, 27),
|
||||
toml::local_time(7, 32, 0), toml::time_offset(0, 0)));
|
||||
BOOST_CHECK_EQUAL(toml::find(owner, "dob").comments().at(0),
|
||||
BOOST_TEST(toml::find(owner, "dob").comments().at(0) ==
|
||||
" First class dates? Why not?");
|
||||
}
|
||||
|
||||
const auto& database = toml::find(data, "database");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(database, "server"), "192.168.1.1");
|
||||
BOOST_TEST(toml::find<std::string>(database, "server") == "192.168.1.1");
|
||||
const std::vector<int> expected_ports{8001, 8001, 8002};
|
||||
BOOST_CHECK(toml::find<std::vector<int>>(database, "ports") == expected_ports);
|
||||
BOOST_CHECK_EQUAL(toml::find<int >(database, "connection_max"), 5000);
|
||||
BOOST_CHECK_EQUAL(toml::find<bool>(database, "enabled"), true);
|
||||
BOOST_TEST(toml::find<int >(database, "connection_max") == 5000);
|
||||
BOOST_TEST(toml::find<bool>(database, "enabled") == true);
|
||||
}
|
||||
|
||||
const auto& servers = toml::find(data, "servers");
|
||||
{
|
||||
const auto& alpha = toml::find(servers, "alpha");
|
||||
BOOST_CHECK_EQUAL(alpha.comments().at(0),
|
||||
BOOST_TEST(alpha.comments().at(0) ==
|
||||
" You can indent as you please. Tabs or spaces. TOML don't care.");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(alpha, "ip"), "10.0.0.1");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(alpha, "dc"), "eqdc10");
|
||||
BOOST_TEST(toml::find<std::string>(alpha, "ip") == "10.0.0.1");
|
||||
BOOST_TEST(toml::find<std::string>(alpha, "dc") == "eqdc10");
|
||||
|
||||
const auto& beta = toml::find(servers, "beta");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(beta, "ip"), "10.0.0.2");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(beta, "dc"), "eqdc10");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(beta, "country"),
|
||||
BOOST_TEST(toml::find<std::string>(beta, "ip") == "10.0.0.2");
|
||||
BOOST_TEST(toml::find<std::string>(beta, "dc") == "eqdc10");
|
||||
BOOST_TEST(toml::find<std::string>(beta, "country") ==
|
||||
"\xE4\xB8\xAD\xE5\x9B\xBD");
|
||||
BOOST_CHECK_EQUAL(toml::find(beta, "country").comments().at(0),
|
||||
BOOST_TEST(toml::find(beta, "country").comments().at(0) ==
|
||||
" This should be parsed as UTF-8");
|
||||
}
|
||||
|
||||
const auto& clients = toml::find(data, "clients");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::find(clients, "data").comments().at(0),
|
||||
BOOST_TEST(toml::find(clients, "data").comments().at(0) ==
|
||||
" just an update to make sure parsers support it");
|
||||
|
||||
|
||||
@@ -283,23 +285,23 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_comment)
|
||||
BOOST_CHECK(toml::find<std::vector<std::string>>(clients, "hosts") ==
|
||||
expected_hosts);
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find(clients, "hosts").comments().at(0),
|
||||
BOOST_TEST(toml::find(clients, "hosts").comments().at(0) ==
|
||||
" Line breaks are OK when inside arrays");
|
||||
}
|
||||
|
||||
std::vector<toml::table> products =
|
||||
toml::find<std::vector<toml::table>>(data, "products");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(products.at(0).at("name")),
|
||||
BOOST_TEST(toml::get<std::string>(products.at(0).at("name")) ==
|
||||
"Hammer");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::int64_t>(products.at(0).at("sku")),
|
||||
BOOST_TEST(toml::get<std::int64_t>(products.at(0).at("sku")) ==
|
||||
738594937);
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(products.at(1).at("name")),
|
||||
BOOST_TEST(toml::get<std::string>(products.at(1).at("name")) ==
|
||||
"Nail");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::int64_t>(products.at(1).at("sku")),
|
||||
BOOST_TEST(toml::get<std::int64_t>(products.at(1).at("sku")) ==
|
||||
284758393);
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(products.at(1).at("color")),
|
||||
BOOST_TEST(toml::get<std::string>(products.at(1).at("color")) ==
|
||||
"gray");
|
||||
}
|
||||
}
|
||||
@@ -316,49 +318,49 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_stdmap_stddeque)
|
||||
std::deque<typename std::remove_cv<decltype(data)>::type>
|
||||
>::value, "");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "title"), "TOML Example");
|
||||
BOOST_TEST(toml::find<std::string>(data, "title") == "TOML Example");
|
||||
const auto& owner = toml::find(data, "owner");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(owner, "name"), "Tom Preston-Werner");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(owner, "organization"), "GitHub");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(owner, "bio"),
|
||||
BOOST_TEST(toml::find<std::string>(owner, "name") == "Tom Preston-Werner");
|
||||
BOOST_TEST(toml::find<std::string>(owner, "organization") == "GitHub");
|
||||
BOOST_TEST(toml::find<std::string>(owner, "bio") ==
|
||||
"GitHub Cofounder & CEO\nLikes tater tots and beer.");
|
||||
BOOST_CHECK_EQUAL(toml::find<toml::offset_datetime>(owner, "dob"),
|
||||
BOOST_TEST(toml::find<toml::offset_datetime>(owner, "dob") ==
|
||||
toml::offset_datetime(toml::local_date(1979, toml::month_t::May, 27),
|
||||
toml::local_time(7, 32, 0), toml::time_offset(0, 0)));
|
||||
BOOST_CHECK_EQUAL(toml::find(owner, "dob").comments().at(0),
|
||||
BOOST_TEST(toml::find(owner, "dob").comments().at(0) ==
|
||||
" First class dates? Why not?");
|
||||
}
|
||||
|
||||
const auto& database = toml::find(data, "database");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(database, "server"), "192.168.1.1");
|
||||
BOOST_TEST(toml::find<std::string>(database, "server") == "192.168.1.1");
|
||||
const std::vector<int> expected_ports{8001, 8001, 8002};
|
||||
BOOST_CHECK(toml::find<std::vector<int>>(database, "ports") == expected_ports);
|
||||
BOOST_CHECK_EQUAL(toml::find<int >(database, "connection_max"), 5000);
|
||||
BOOST_CHECK_EQUAL(toml::find<bool>(database, "enabled"), true);
|
||||
BOOST_TEST(toml::find<int >(database, "connection_max") == 5000);
|
||||
BOOST_TEST(toml::find<bool>(database, "enabled") == true);
|
||||
}
|
||||
|
||||
const auto& servers = toml::find(data, "servers");
|
||||
{
|
||||
const auto& alpha = toml::find(servers, "alpha");
|
||||
BOOST_CHECK_EQUAL(alpha.comments().at(0),
|
||||
BOOST_TEST(alpha.comments().at(0) ==
|
||||
" You can indent as you please. Tabs or spaces. TOML don't care.");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(alpha, "ip"), "10.0.0.1");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(alpha, "dc"), "eqdc10");
|
||||
BOOST_TEST(toml::find<std::string>(alpha, "ip") == "10.0.0.1");
|
||||
BOOST_TEST(toml::find<std::string>(alpha, "dc") == "eqdc10");
|
||||
|
||||
const auto& beta = toml::find(servers, "beta");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(beta, "ip"), "10.0.0.2");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(beta, "dc"), "eqdc10");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(beta, "country"),
|
||||
BOOST_TEST(toml::find<std::string>(beta, "ip") == "10.0.0.2");
|
||||
BOOST_TEST(toml::find<std::string>(beta, "dc") == "eqdc10");
|
||||
BOOST_TEST(toml::find<std::string>(beta, "country") ==
|
||||
"\xE4\xB8\xAD\xE5\x9B\xBD");
|
||||
BOOST_CHECK_EQUAL(toml::find(beta, "country").comments().at(0),
|
||||
BOOST_TEST(toml::find(beta, "country").comments().at(0) ==
|
||||
" This should be parsed as UTF-8");
|
||||
}
|
||||
|
||||
const auto& clients = toml::find(data, "clients");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::find(clients, "data").comments().at(0),
|
||||
BOOST_TEST(toml::find(clients, "data").comments().at(0) ==
|
||||
" just an update to make sure parsers support it");
|
||||
|
||||
|
||||
@@ -373,23 +375,23 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_stdmap_stddeque)
|
||||
BOOST_CHECK(toml::find<std::vector<std::string>>(clients, "hosts") ==
|
||||
expected_hosts);
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find(clients, "hosts").comments().at(0),
|
||||
BOOST_TEST(toml::find(clients, "hosts").comments().at(0) ==
|
||||
" Line breaks are OK when inside arrays");
|
||||
}
|
||||
|
||||
std::vector<toml::table> products =
|
||||
toml::find<std::vector<toml::table>>(data, "products");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(products.at(0).at("name")),
|
||||
BOOST_TEST(toml::get<std::string>(products.at(0).at("name")) ==
|
||||
"Hammer");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::int64_t>(products.at(0).at("sku")),
|
||||
BOOST_TEST(toml::get<std::int64_t>(products.at(0).at("sku")) ==
|
||||
738594937);
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(products.at(1).at("name")),
|
||||
BOOST_TEST(toml::get<std::string>(products.at(1).at("name")) ==
|
||||
"Nail");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::int64_t>(products.at(1).at("sku")),
|
||||
BOOST_TEST(toml::get<std::int64_t>(products.at(1).at("sku")) ==
|
||||
284758393);
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(products.at(1).at("color")),
|
||||
BOOST_TEST(toml::get<std::string>(products.at(1).at("color")) ==
|
||||
"gray");
|
||||
}
|
||||
}
|
||||
@@ -409,8 +411,8 @@ BOOST_AUTO_TEST_CASE(test_file_with_BOM)
|
||||
std::istringstream iss(table);
|
||||
const auto data = toml::parse(iss, "test_file_with_BOM.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -425,8 +427,8 @@ BOOST_AUTO_TEST_CASE(test_file_with_BOM)
|
||||
}
|
||||
const auto data = toml::parse("tmp.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -438,8 +440,8 @@ BOOST_AUTO_TEST_CASE(test_file_with_BOM)
|
||||
std::istringstream iss(table);
|
||||
const auto data = toml::parse(iss, "test_file_with_BOM_CRLF.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -457,8 +459,8 @@ BOOST_AUTO_TEST_CASE(test_file_with_BOM)
|
||||
}
|
||||
const auto data = toml::parse("tmp.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,8 +476,8 @@ BOOST_AUTO_TEST_CASE(test_file_without_newline_at_the_end_of_file)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_file_without_newline_at_the_end_of_file.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -487,8 +489,8 @@ BOOST_AUTO_TEST_CASE(test_file_without_newline_at_the_end_of_file)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_file_without_newline_at_the_end_of_file_CRLF.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -501,8 +503,8 @@ BOOST_AUTO_TEST_CASE(test_file_without_newline_at_the_end_of_file)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_file_without_newline_at_the_end_of_file_comment.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -514,8 +516,8 @@ BOOST_AUTO_TEST_CASE(test_file_without_newline_at_the_end_of_file)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_file_without_newline_at_the_end_of_file_comment.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -528,8 +530,8 @@ BOOST_AUTO_TEST_CASE(test_file_without_newline_at_the_end_of_file)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_file_without_newline_at_the_end_of_file_ws.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -541,8 +543,8 @@ BOOST_AUTO_TEST_CASE(test_file_without_newline_at_the_end_of_file)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_file_without_newline_at_the_end_of_file_ws.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -561,8 +563,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_comment)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_comment.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -576,8 +578,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_comment)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_comment.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
|
||||
// comment w/ newline
|
||||
@@ -593,8 +595,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_comment)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_comment.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -608,8 +610,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_comment)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_comment.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
|
||||
// CRLF version
|
||||
@@ -625,8 +627,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_comment)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_comment.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -640,8 +642,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_comment)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_comment.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -654,8 +656,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_comment)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_comment.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -669,8 +671,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_comment)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_comment.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -688,8 +690,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_empty_lines)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_newline.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -703,8 +705,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_empty_lines)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_newline.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
|
||||
// with whitespaces
|
||||
@@ -720,8 +722,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_empty_lines)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_newline.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -735,8 +737,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_empty_lines)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_newline.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -750,8 +752,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_empty_lines)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_newline.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -765,8 +767,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_empty_lines)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_newline.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
|
||||
// with whitespaces but no newline
|
||||
@@ -781,8 +783,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_empty_lines)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_newline.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
|
||||
|
||||
@@ -799,8 +801,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_empty_lines)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_newline.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -814,8 +816,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_empty_lines)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_newline.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
|
||||
// with whitespaces
|
||||
@@ -831,8 +833,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_empty_lines)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_newline.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -846,8 +848,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_empty_lines)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_newline.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -861,8 +863,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_empty_lines)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_newline.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -876,8 +878,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_empty_lines)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_newline.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -890,8 +892,8 @@ BOOST_AUTO_TEST_CASE(test_files_end_with_empty_lines)
|
||||
const auto data = toml::parse(iss,
|
||||
"test_files_end_with_newline.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
BOOST_TEST(toml::find<std::string>(data, "key") == "value");
|
||||
BOOST_TEST(toml::find<std::string>(toml::find(data, "table"), "key") == "value");
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user