From 46569da231b86bfddc4e1a12e0ede3df5b36b5b8 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Wed, 13 Feb 2019 19:51:54 +0900 Subject: [PATCH] fix: avoid auto-conversion while making test case --- tests/test_parse_file.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_parse_file.cpp b/tests/test_parse_file.cpp index a38e9c9..b5c6a8a 100644 --- a/tests/test_parse_file.cpp +++ b/tests/test_parse_file.cpp @@ -250,8 +250,11 @@ BOOST_AUTO_TEST_CASE(test_file_with_BOM) "key = \"value\"\r\n" ); { - std::ofstream ofs("tmp.toml"); - ofs << table; + // 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");