#include #include #include #include #include #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; for (int i=1;i("bool") && *params.get("bool") == true)); params["bool"] = "true"; BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); params["bool"] = mapnik::value_integer(1); BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); params["bool"] = "1"; BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); params["bool"] = "True"; BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); params["bool"] = "on"; BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); params["bool"] = "yes"; BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); // false params["bool"] = mapnik::value_integer(false); BOOST_TEST( (params.get("bool") && *params.get("bool") == false) ); params["bool"] = "false"; BOOST_TEST( (params.get("bool") && *params.get("bool") == false) ); params["bool"] = mapnik::value_integer(0); BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); params["bool"] = "0"; BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); params["bool"] = "False"; BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); params["bool"] = "off"; BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); params["bool"] = "no"; BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); // strings params["string"] = "hello"; BOOST_TEST( (params.get("string") && *params.get("string") == "hello") ); // int params["int"] = mapnik::value_integer(1); BOOST_TEST( (params.get("int") && *params.get("int") == 1) ); // double params["double"] = 1.5; BOOST_TEST( (params.get("double") && *params.get("double") == 1.5) ); // value_null 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) { std::cerr << ex.what() << "\n"; BOOST_TEST(false); } if (!::boost::detail::test_errors()) { if (quiet) std::clog << "\x1b[1;32m.\x1b[0m"; else std::clog << "C++ parameters: \x1b[1;32m✓ \x1b[0m\n"; ::boost::detail::report_errors_remind().called_report_errors_function = true; } else { return ::boost::report_errors(); } }