mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:58:09 +08:00
test: update retval of parse and related get/find
This commit is contained in:
@@ -14,42 +14,42 @@ BOOST_AUTO_TEST_CASE(test_example)
|
||||
{
|
||||
const auto data = toml::parse("toml/tests/example.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(data.at("title")), "TOML Example");
|
||||
toml::Table owner = toml::get<toml::Table>(data.at("owner"));
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "title"), "TOML Example");
|
||||
const auto& owner = toml::find(data, "owner");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(owner.at("name")), "Tom Preston-Werner");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(owner.at("organization")), "GitHub");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(owner.at("bio")),
|
||||
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"),
|
||||
"GitHub Cofounder & CEO\nLikes tater tots and beer.");
|
||||
BOOST_CHECK_EQUAL(toml::get<toml::Datetime>(owner.at("dob")),
|
||||
BOOST_CHECK_EQUAL(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)));
|
||||
}
|
||||
|
||||
toml::Table database = toml::get<toml::Table>(data.at("database"));
|
||||
const auto& database = toml::find(data, "database");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(database.at("server")), "192.168.1.1");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(database, "server"), "192.168.1.1");
|
||||
const std::vector<int> expected_ports{8001, 8001, 8002};
|
||||
BOOST_CHECK(toml::get<std::vector<int>>(database.at("ports")) == expected_ports);
|
||||
BOOST_CHECK_EQUAL(toml::get<int>(database.at("connection_max")), 5000);
|
||||
BOOST_CHECK_EQUAL(toml::get<bool>(database.at("enabled")), true);
|
||||
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);
|
||||
}
|
||||
|
||||
toml::Table servers = toml::get<toml::Table>(data.at("servers"));
|
||||
const auto& servers = toml::find(data, "servers");
|
||||
{
|
||||
toml::Table alpha = toml::get<toml::Table>(servers.at("alpha"));
|
||||
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");
|
||||
|
||||
toml::Table beta = toml::get<toml::Table>(servers.at("beta"));
|
||||
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");
|
||||
}
|
||||
|
||||
toml::Table clients = toml::get<toml::Table>(data.at("clients"));
|
||||
const auto& clients = toml::find(data, "clients");
|
||||
{
|
||||
toml::Array clients_data = toml::get<toml::Array>(clients.at("data"));
|
||||
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);
|
||||
@@ -57,12 +57,12 @@ BOOST_AUTO_TEST_CASE(test_example)
|
||||
BOOST_CHECK(toml::get<std::vector<int>>(clients_data.at(1)) ==
|
||||
expected_number);
|
||||
std::vector<std::string> expected_hosts{"alpha", "omega"};
|
||||
BOOST_CHECK(toml::get<std::vector<std::string>>(clients.at("hosts")) ==
|
||||
BOOST_CHECK(toml::find<std::vector<std::string>>(clients, "hosts") ==
|
||||
expected_hosts);
|
||||
}
|
||||
|
||||
std::vector<toml::Table> products =
|
||||
toml::get<std::vector<toml::Table>>(data.at("products"));
|
||||
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");
|
||||
@@ -83,42 +83,42 @@ BOOST_AUTO_TEST_CASE(test_example_stream)
|
||||
std::ifstream ifs("toml/tests/example.toml");
|
||||
const auto data = toml::parse(ifs);
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(data.at("title")), "TOML Example");
|
||||
toml::Table owner = toml::get<toml::Table>(data.at("owner"));
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "title"), "TOML Example");
|
||||
const auto& owner = toml::find(data, "owner");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(owner.at("name")), "Tom Preston-Werner");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(owner.at("organization")), "GitHub");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(owner.at("bio")),
|
||||
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"),
|
||||
"GitHub Cofounder & CEO\nLikes tater tots and beer.");
|
||||
BOOST_CHECK_EQUAL(toml::get<toml::Datetime>(owner.at("dob")),
|
||||
BOOST_CHECK_EQUAL(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)));
|
||||
}
|
||||
|
||||
toml::Table database = toml::get<toml::Table>(data.at("database"));
|
||||
const auto& database = toml::find(data, "database");
|
||||
{
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(database.at("server")), "192.168.1.1");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(database, "server"), "192.168.1.1");
|
||||
const std::vector<int> expected_ports{8001, 8001, 8002};
|
||||
BOOST_CHECK(toml::get<std::vector<int>>(database.at("ports")) == expected_ports);
|
||||
BOOST_CHECK_EQUAL(toml::get<int>(database.at("connection_max")), 5000);
|
||||
BOOST_CHECK_EQUAL(toml::get<bool>(database.at("enabled")), true);
|
||||
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);
|
||||
}
|
||||
|
||||
toml::Table servers = toml::get<toml::Table>(data.at("servers"));
|
||||
const auto& servers = toml::find(data, "servers");
|
||||
{
|
||||
toml::Table alpha = toml::get<toml::Table>(servers.at("alpha"));
|
||||
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");
|
||||
|
||||
toml::Table beta = toml::get<toml::Table>(servers.at("beta"));
|
||||
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");
|
||||
}
|
||||
|
||||
toml::Table clients = toml::get<toml::Table>(data.at("clients"));
|
||||
const auto& clients = toml::find(data, "clients");
|
||||
{
|
||||
toml::Array clients_data = toml::get<toml::Array>(clients.at("data"));
|
||||
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);
|
||||
@@ -126,12 +126,12 @@ BOOST_AUTO_TEST_CASE(test_example_stream)
|
||||
BOOST_CHECK(toml::get<std::vector<int>>(clients_data.at(1)) ==
|
||||
expected_number);
|
||||
std::vector<std::string> expected_hosts{"alpha", "omega"};
|
||||
BOOST_CHECK(toml::get<std::vector<std::string>>(clients.at("hosts")) ==
|
||||
BOOST_CHECK(toml::find<std::vector<std::string>>(clients, "hosts") ==
|
||||
expected_hosts);
|
||||
}
|
||||
|
||||
std::vector<toml::Table> products =
|
||||
toml::get<std::vector<toml::Table>>(data.at("products"));
|
||||
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");
|
||||
@@ -147,51 +147,49 @@ BOOST_AUTO_TEST_CASE(test_example_stream)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_fruit)
|
||||
{
|
||||
const auto data = toml::parse("toml/tests/fruit.toml");
|
||||
const auto blah = toml::get<std::vector<toml::Table>>(
|
||||
toml::get<toml::Table>(data.at("fruit")).at("blah"));
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(blah.at(0).at("name")), "apple");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(blah.at(1).at("name")), "banana");
|
||||
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");
|
||||
{
|
||||
const auto physical = toml::get<toml::Table>(blah.at(0).at("physical"));
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(physical.at("color")), "red");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(physical.at("shape")), "round");
|
||||
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");
|
||||
}
|
||||
{
|
||||
const auto physical = toml::get<toml::Table>(blah.at(1).at("physical"));
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(physical.at("color")), "yellow");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(physical.at("shape")), "bent");
|
||||
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_AUTO_TEST_CASE(test_hard_example)
|
||||
{
|
||||
const auto data = toml::parse("toml/tests/hard_example.toml");
|
||||
const auto the = toml::get<toml::Table>(data.at("the"));
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(the.at("test_string")),
|
||||
const auto the = toml::find(data, "the");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(the, "test_string"),
|
||||
"You'll hate me after this - #");
|
||||
|
||||
const auto hard = toml::get<toml::Table>(the.at("hard"));
|
||||
const auto hard = toml::find(the, "hard");
|
||||
const std::vector<std::string> expected_the_hard_test_array{"] ", " # "};
|
||||
BOOST_CHECK(toml::get<std::vector<std::string>>(hard.at("test_array")) ==
|
||||
BOOST_CHECK(toml::find<std::vector<std::string>>(hard, "test_array") ==
|
||||
expected_the_hard_test_array);
|
||||
const std::vector<std::string> expected_the_hard_test_array2{
|
||||
"Test #11 ]proved that", "Experiment #9 was a success"};
|
||||
BOOST_CHECK(toml::get<std::vector<std::string>>(hard.at("test_array2")) ==
|
||||
BOOST_CHECK(toml::find<std::vector<std::string>>(hard, "test_array2") ==
|
||||
expected_the_hard_test_array2);
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(hard.at("another_test_string")),
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(hard, "another_test_string"),
|
||||
" Same thing, but with a string #");
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(hard.at("harder_test_string")),
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(hard, "harder_test_string"),
|
||||
" And when \"'s are in the string, along with # \"");
|
||||
|
||||
const auto bit = toml::get<toml::Table>(hard.at("bit#"));
|
||||
BOOST_CHECK_EQUAL(toml::get<std::string>(bit.at("what?")),
|
||||
const auto bit = toml::find(hard, "bit#");
|
||||
BOOST_CHECK_EQUAL(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::get<std::vector<std::string>>(bit.at("multi_line_array")) ==
|
||||
BOOST_CHECK(toml::find<std::vector<std::string>>(bit, "multi_line_array") ==
|
||||
expected_multi_line_array);
|
||||
}
|
||||
|
||||
@@ -210,8 +208,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -226,8 +224,8 @@ BOOST_AUTO_TEST_CASE(test_file_with_BOM)
|
||||
}
|
||||
const auto data = toml::parse("tmp.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -239,8 +237,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -258,8 +256,8 @@ BOOST_AUTO_TEST_CASE(test_file_with_BOM)
|
||||
}
|
||||
const auto data = toml::parse("tmp.toml");
|
||||
|
||||
BOOST_CHECK_EQUAL(toml::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,8 +273,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -288,8 +286,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -302,8 +300,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -315,8 +313,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -329,8 +327,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -342,8 +340,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,8 +360,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -377,8 +375,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
|
||||
// comment w/ newline
|
||||
@@ -394,8 +392,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -409,8 +407,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
|
||||
// CRLF version
|
||||
@@ -426,8 +424,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -441,8 +439,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -455,8 +453,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -470,8 +468,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,8 +487,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -504,8 +502,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
|
||||
// with whitespaces
|
||||
@@ -521,8 +519,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -536,8 +534,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -551,8 +549,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -566,8 +564,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
|
||||
// with whitespaces but no newline
|
||||
@@ -582,8 +580,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
|
||||
|
||||
@@ -600,8 +598,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -615,8 +613,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
|
||||
// with whitespaces
|
||||
@@ -632,8 +630,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -647,8 +645,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -662,8 +660,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -677,8 +675,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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
@@ -691,7 +689,7 @@ 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::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data, "key"), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(toml::find(data, "table"), "key"), "value");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user