mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 00:38:08 +08:00
Merge branch 'master' into serialize
This commit is contained in:
@@ -213,6 +213,22 @@ BOOST_AUTO_TEST_CASE(test_file_with_BOM)
|
||||
BOOST_CHECK_EQUAL(toml::get <std::string>(data.at("key")), "value");
|
||||
BOOST_CHECK_EQUAL(toml::find<std::string>(data.at("table"), "key"), "value");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
"\xEF\xBB\xBF" // BOM
|
||||
"key = \"value\"\n"
|
||||
"[table]\n"
|
||||
"key = \"value\"\n"
|
||||
);
|
||||
{
|
||||
std::ofstream ofs("tmp.toml");
|
||||
ofs << table;
|
||||
}
|
||||
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");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
"\xEF\xBB\xBF" // BOM
|
||||
@@ -223,6 +239,25 @@ 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");
|
||||
}
|
||||
{
|
||||
const std::string table(
|
||||
"\xEF\xBB\xBF" // BOM
|
||||
"key = \"value\"\r\n"
|
||||
"[table]\r\n"
|
||||
"key = \"value\"\r\n"
|
||||
);
|
||||
{
|
||||
// with text-mode, "\n" is converted to "\r\n" and the resulting
|
||||
// value will be "\r\r\n". To avoid the additional "\r", use binary
|
||||
// mode.
|
||||
std::ofstream ofs("tmp.toml", std::ios_base::binary);
|
||||
ofs.write(table.data(), table.size());
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
Reference in New Issue
Block a user