2012-03-24 03:04:42 +00:00
|
|
|
|
|
|
|
#include <boost/detail/lightweight_test.hpp>
|
|
|
|
#include <iostream>
|
|
|
|
#include <mapnik/params.hpp>
|
|
|
|
#include <mapnik/boolean.hpp>
|
|
|
|
|
|
|
|
int main( int, char*[] )
|
|
|
|
{
|
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
mapnik::parameters params;
|
2012-03-24 03:04:42 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
// true
|
|
|
|
params["bool"] = true;
|
|
|
|
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == true));
|
2012-03-24 03:04:42 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
params["bool"] = "true";
|
|
|
|
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == true));
|
2012-03-24 03:04:42 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
params["bool"] = 1;
|
|
|
|
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == true));
|
2012-03-24 03:04:42 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
params["bool"] = "1";
|
|
|
|
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == true));
|
2012-03-24 03:04:42 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
params["bool"] = "True";
|
|
|
|
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == true));
|
2012-03-24 03:04:42 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
params["bool"] = "on";
|
|
|
|
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == true));
|
2012-03-24 03:04:42 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
params["bool"] = "yes";
|
|
|
|
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == true));
|
2012-03-24 03:04:42 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
// false
|
|
|
|
params["bool"] = false;
|
|
|
|
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == false) );
|
2012-03-24 03:04:42 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
params["bool"] = "false";
|
|
|
|
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == false) );
|
2012-03-24 03:04:42 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
params["bool"] = 0;
|
|
|
|
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == false));
|
2012-03-24 03:04:42 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
params["bool"] = "0";
|
|
|
|
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == false));
|
2012-03-24 03:04:42 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
params["bool"] = "False";
|
|
|
|
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == false));
|
2012-03-24 03:04:42 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
params["bool"] = "off";
|
|
|
|
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == false));
|
2012-03-24 03:04:42 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
params["bool"] = "no";
|
|
|
|
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == false));
|
2012-04-06 21:20:04 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
// strings
|
|
|
|
params["string"] = "hello";
|
|
|
|
BOOST_TEST( (params.get<std::string>("string") && *params.get<std::string>("string") == "hello") );
|
2012-04-06 21:20:04 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
// int
|
|
|
|
params["int"] = 1;
|
|
|
|
BOOST_TEST( (params.get<int>("int") && *params.get<int>("int") == 1) );
|
2012-04-06 21:20:04 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
// double
|
|
|
|
params["double"] = 1.5;
|
|
|
|
BOOST_TEST( (params.get<double>("double") && *params.get<double>("double") == 1.5) );
|
2012-04-06 21:20:04 +00:00
|
|
|
|
2012-04-17 05:33:37 +00:00
|
|
|
// value_null
|
|
|
|
params["null"] = mapnik::value_null();
|
|
|
|
//BOOST_TEST( (params.get<mapnik::value_null>("null")/* && *params.get<mapnik::value_null>("null") == mapnik::value_null()*/) );
|
|
|
|
|
|
|
|
if (!::boost::detail::test_errors()) {
|
|
|
|
std::clog << "C++ parameters: \x1b[1;32m✓ \x1b[0m\n";
|
|
|
|
} else {
|
|
|
|
return ::boost::report_errors();
|
|
|
|
}
|
2012-03-24 03:04:42 +00:00
|
|
|
}
|