From 2466959cf923f8f236aca898c32d2d861d0f7a1a Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Wed, 20 Mar 2024 22:42:00 +0900 Subject: [PATCH] chore: avoid false-positive ref life warning --- tests/test_comments.cpp | 34 +++++++++++++-------------- tests/test_parse_file.cpp | 48 +++++++++++++++++++-------------------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/tests/test_comments.cpp b/tests/test_comments.cpp index 2d2b6a6..5b9116d 100644 --- a/tests/test_comments.cpp +++ b/tests/test_comments.cpp @@ -14,8 +14,8 @@ BOOST_AUTO_TEST_CASE(test_comment_before) std::istringstream iss(file); const auto v = toml::parse(iss); - const auto& a = toml::find(v, "a"); - const auto& b = toml::find(v, "b"); + const auto a = toml::find(v, "a"); + const auto b = toml::find(v, "b"); BOOST_TEST(a.comments().size() == 1u); BOOST_TEST(a.comments().front() == " comment for a."); @@ -35,8 +35,8 @@ BOOST_AUTO_TEST_CASE(test_comment_before) std::istringstream iss(file); const auto v = toml::parse(iss); - const auto& a = toml::find(v, "a"); - const auto& b = toml::find(v, "b"); + const auto a = toml::find(v, "a"); + const auto b = toml::find(v, "b"); BOOST_TEST(a.comments().size() == 2u); BOOST_TEST(a.comments().front() == " comment for a."); @@ -58,8 +58,8 @@ BOOST_AUTO_TEST_CASE(test_comment_inline) std::istringstream iss(file); const auto v = toml::parse(iss); - const auto& a = toml::find(v, "a"); - const auto& b = toml::find(v, "b"); + const auto a = toml::find(v, "a"); + const auto b = toml::find(v, "b"); BOOST_TEST(a.comments().size() == 1u); BOOST_TEST(a.comments().front() == " comment for a."); @@ -79,9 +79,9 @@ BOOST_AUTO_TEST_CASE(test_comment_inline) std::istringstream iss(file); const auto v = toml::parse(iss); - const auto& a = toml::find(v, "a"); - const auto& b = toml::find(v, "b"); - const auto& b0 = b.as_array().at(0); + const auto a = toml::find(v, "a"); + const auto b = toml::find(v, "b"); + const auto b0 = b.as_array().at(0); BOOST_TEST(a.comments().size() == 1u); BOOST_TEST(a.comments().front() == " comment for a."); @@ -110,10 +110,10 @@ BOOST_AUTO_TEST_CASE(test_comment_both) std::istringstream iss(file); const auto v = toml::parse(iss); - const auto& a = toml::find(v, "a"); - const auto& b = toml::find(v, "b"); - const auto& c = toml::find(v, "c"); - const auto& c0 = c.as_array().at(0); + const auto a = toml::find(v, "a"); + const auto b = toml::find(v, "b"); + const auto c = toml::find(v, "c"); + const auto c0 = c.as_array().at(0); BOOST_TEST(a.comments().size() == 2u); BOOST_TEST(a.comments().front() == " comment for a."); @@ -186,10 +186,10 @@ BOOST_AUTO_TEST_CASE(test_discard_comment) std::istringstream iss(file); const auto v = toml::parse(iss); - const auto& a = toml::find(v, "a"); - const auto& b = toml::find(v, "b"); - const auto& c = toml::find(v, "c"); - const auto& c0 = c.as_array().at(0); + const auto a = toml::find(v, "a"); + const auto b = toml::find(v, "b"); + const auto c = toml::find(v, "c"); + const auto c0 = c.as_array().at(0); BOOST_TEST(a.comments().empty()); BOOST_TEST(b.comments().empty()); diff --git a/tests/test_parse_file.cpp b/tests/test_parse_file.cpp index 2c45670..92d8028 100644 --- a/tests/test_parse_file.cpp +++ b/tests/test_parse_file.cpp @@ -12,7 +12,7 @@ BOOST_AUTO_TEST_CASE(test_example) const auto data = toml::parse(testinput("example.toml")); BOOST_TEST(toml::find(data, "title") == "TOML Example"); - const auto& owner = toml::find(data, "owner"); + const auto owner = toml::find(data, "owner"); { BOOST_TEST(toml::find(owner, "name") == "Tom Preston-Werner"); BOOST_TEST(toml::find(owner, "organization") == "GitHub"); @@ -23,7 +23,7 @@ BOOST_AUTO_TEST_CASE(test_example) toml::local_time(7, 32, 0), toml::time_offset(0, 0))); } - const auto& database = toml::find(data, "database"); + const auto database = toml::find(data, "database"); { BOOST_TEST(toml::find(database, "server") == "192.168.1.1"); const std::vector expected_ports{8001, 8001, 8002}; @@ -32,7 +32,7 @@ BOOST_AUTO_TEST_CASE(test_example) BOOST_TEST(toml::find(database, "enabled") == true); } - const auto& servers = toml::find(data, "servers"); + const auto servers = toml::find(data, "servers"); { toml::table alpha = toml::find(servers, "alpha"); BOOST_TEST(toml::get(alpha.at("ip")) == "10.0.0.1"); @@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE(test_example) BOOST_TEST(toml::get(beta.at("country")) == "\xE4\xB8\xAD\xE5\x9B\xBD"); } - const auto& clients = toml::find(data, "clients"); + const auto clients = toml::find(data, "clients"); { toml::array clients_data = toml::find(clients, "data"); @@ -76,7 +76,7 @@ BOOST_AUTO_TEST_CASE(test_example_stream) const auto data = toml::parse(ifs); BOOST_TEST(toml::find(data, "title") == "TOML Example"); - const auto& owner = toml::find(data, "owner"); + const auto owner = toml::find(data, "owner"); { BOOST_TEST(toml::find(owner, "name") == "Tom Preston-Werner"); BOOST_TEST(toml::find(owner, "organization") == "GitHub"); @@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(test_example_stream) toml::local_time(7, 32, 0), toml::time_offset(0, 0))); } - const auto& database = toml::find(data, "database"); + const auto database = toml::find(data, "database"); { BOOST_TEST(toml::find(database, "server") == "192.168.1.1"); const std::vector expected_ports{8001, 8001, 8002}; @@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE(test_example_stream) BOOST_TEST(toml::find(database, "enabled") == true); } - const auto& servers = toml::find(data, "servers"); + const auto servers = toml::find(data, "servers"); { toml::table alpha = toml::find(servers, "alpha"); BOOST_TEST(toml::get(alpha.at("ip")) == "10.0.0.1"); @@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE(test_example_stream) BOOST_TEST(toml::get(beta.at("country")) == "\xE4\xB8\xAD\xE5\x9B\xBD"); } - const auto& clients = toml::find(data, "clients"); + const auto clients = toml::find(data, "clients"); { toml::array clients_data = toml::find(clients, "data"); std::vector expected_name{"gamma", "delta"}; @@ -145,7 +145,7 @@ BOOST_AUTO_TEST_CASE(test_example_file_pointer) fclose(file); BOOST_TEST(toml::find(data, "title") == "TOML Example"); - const auto& owner = toml::find(data, "owner"); + const auto owner = toml::find(data, "owner"); { BOOST_TEST(toml::find(owner, "name") == "Tom Preston-Werner"); BOOST_TEST(toml::find(owner, "organization") == "GitHub"); @@ -156,7 +156,7 @@ BOOST_AUTO_TEST_CASE(test_example_file_pointer) toml::local_time(7, 32, 0), toml::time_offset(0, 0))); } - const auto& database = toml::find(data, "database"); + const auto database = toml::find(data, "database"); { BOOST_TEST(toml::find(database, "server") == "192.168.1.1"); const std::vector expected_ports{8001, 8001, 8002}; @@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE(test_example_file_pointer) BOOST_TEST(toml::find(database, "enabled") == true); } - const auto& servers = toml::find(data, "servers"); + const auto servers = toml::find(data, "servers"); { toml::table alpha = toml::find(servers, "alpha"); BOOST_TEST(toml::get(alpha.at("ip")) == "10.0.0.1"); @@ -177,7 +177,7 @@ BOOST_AUTO_TEST_CASE(test_example_file_pointer) BOOST_TEST(toml::get(beta.at("country")) == "\xE4\xB8\xAD\xE5\x9B\xBD"); } - const auto& clients = toml::find(data, "clients"); + const auto clients = toml::find(data, "clients"); { toml::array clients_data = toml::find(clients, "data"); std::vector expected_name{"gamma", "delta"}; @@ -286,7 +286,7 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_comment) const auto data = toml::parse(testinput("example.toml")); BOOST_TEST(toml::find(data, "title") == "TOML Example"); - const auto& owner = toml::find(data, "owner"); + const auto owner = toml::find(data, "owner"); { BOOST_TEST(toml::find(owner, "name") == "Tom Preston-Werner"); BOOST_TEST(toml::find(owner, "organization") == "GitHub"); @@ -299,7 +299,7 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_comment) " First class dates? Why not?"); } - const auto& database = toml::find(data, "database"); + const auto database = toml::find(data, "database"); { BOOST_TEST(toml::find(database, "server") == "192.168.1.1"); const std::vector expected_ports{8001, 8001, 8002}; @@ -308,15 +308,15 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_comment) BOOST_TEST(toml::find(database, "enabled") == true); } - const auto& servers = toml::find(data, "servers"); + const auto servers = toml::find(data, "servers"); { - const auto& alpha = toml::find(servers, "alpha"); + const auto alpha = toml::find(servers, "alpha"); BOOST_TEST(alpha.comments().at(0) == " You can indent as you please. Tabs or spaces. TOML don't care."); BOOST_TEST(toml::find(alpha, "ip") == "10.0.0.1"); BOOST_TEST(toml::find(alpha, "dc") == "eqdc10"); - const auto& beta = toml::find(servers, "beta"); + const auto beta = toml::find(servers, "beta"); BOOST_TEST(toml::find(beta, "ip") == "10.0.0.2"); BOOST_TEST(toml::find(beta, "dc") == "eqdc10"); BOOST_TEST(toml::find(beta, "country") == @@ -325,7 +325,7 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_comment) " This should be parsed as UTF-8"); } - const auto& clients = toml::find(data, "clients"); + const auto clients = toml::find(data, "clients"); { BOOST_TEST(toml::find(clients, "data").comments().at(0) == " just an update to make sure parsers support it"); @@ -376,7 +376,7 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_stdmap_stddeque) >::value, ""); BOOST_TEST(toml::find(data, "title") == "TOML Example"); - const auto& owner = toml::find(data, "owner"); + const auto owner = toml::find(data, "owner"); { BOOST_TEST(toml::find(owner, "name") == "Tom Preston-Werner"); BOOST_TEST(toml::find(owner, "organization") == "GitHub"); @@ -389,7 +389,7 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_stdmap_stddeque) " First class dates? Why not?"); } - const auto& database = toml::find(data, "database"); + const auto database = toml::find(data, "database"); { BOOST_TEST(toml::find(database, "server") == "192.168.1.1"); const std::vector expected_ports{8001, 8001, 8002}; @@ -398,15 +398,15 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_stdmap_stddeque) BOOST_TEST(toml::find(database, "enabled") == true); } - const auto& servers = toml::find(data, "servers"); + const auto servers = toml::find(data, "servers"); { - const auto& alpha = toml::find(servers, "alpha"); + const auto alpha = toml::find(servers, "alpha"); BOOST_TEST(alpha.comments().at(0) == " You can indent as you please. Tabs or spaces. TOML don't care."); BOOST_TEST(toml::find(alpha, "ip") == "10.0.0.1"); BOOST_TEST(toml::find(alpha, "dc") == "eqdc10"); - const auto& beta = toml::find(servers, "beta"); + const auto beta = toml::find(servers, "beta"); BOOST_TEST(toml::find(beta, "ip") == "10.0.0.2"); BOOST_TEST(toml::find(beta, "dc") == "eqdc10"); BOOST_TEST(toml::find(beta, "country") == @@ -415,7 +415,7 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_stdmap_stddeque) " This should be parsed as UTF-8"); } - const auto& clients = toml::find(data, "clients"); + const auto clients = toml::find(data, "clients"); { BOOST_TEST(toml::find(clients, "data").comments().at(0) == " just an update to make sure parsers support it");