From fcdc826294ddc9deba90c055611ee1b92b4ccf45 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Thu, 22 Jan 2015 18:25:37 -0800 Subject: [PATCH] Add (currently failing) test for #2651 --- tests/cpp_tests/params_test.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/cpp_tests/params_test.cpp b/tests/cpp_tests/params_test.cpp index 081cc3b08..96497ed0d 100644 --- a/tests/cpp_tests/params_test.cpp +++ b/tests/cpp_tests/params_test.cpp @@ -6,6 +6,22 @@ #include #include +namespace detail { + +class string_holder { + public: + string_holder() : + member_("member") {} + std::string const& get_string() const + { + return member_; + } + private: + std::string member_; +}; + +} + int main(int argc, char** argv) { std::vector args; @@ -79,6 +95,20 @@ int main(int argc, char** argv) params["null"] = mapnik::value_null(); // https://github.com/mapnik/mapnik/issues/2471 //BOOST_TEST( (params.get("null") && *params.get("null") == mapnik::value_null()) ); + + std::string rvalue("rvalue"); + params["rvalue"] = rvalue; + BOOST_TEST(params.get("rvalue") == std::string("rvalue")); + // Currently this fails because rvalue gets moved and nulled out + // Is this really the right behavior? + BOOST_TEST(rvalue == std::string("rvalue")); + + // ensure that const member is not moved incorrectly when added to params + detail::string_holder holder; + std::string const& holder_member = holder.get_string(); + params["member"] = holder_member; + BOOST_TEST(params.get("member") == std::string("member")); + BOOST_TEST(holder_member == std::string("member")); } catch (std::exception const& ex) {