From 46fdc570c2085a426b034bd51df2ba032a256dfd Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Fri, 23 Mar 2012 20:04:42 -0700 Subject: [PATCH] cpp tests for mapnik parameters and mapnik:boolean -refs #1141 --- tests/cpp_tests/params_test.cpp | 57 +++++++++++++++++++++++++++ tests/python_tests/parameters_test.py | 5 +++ 2 files changed, 62 insertions(+) create mode 100644 tests/cpp_tests/params_test.cpp diff --git a/tests/cpp_tests/params_test.cpp b/tests/cpp_tests/params_test.cpp new file mode 100644 index 000000000..86e702366 --- /dev/null +++ b/tests/cpp_tests/params_test.cpp @@ -0,0 +1,57 @@ + +#include +#include +#include +#include + +int main( int, char*[] ) +{ + + mapnik::parameters params; + + // true + params["bool"] = true; + BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); + + params["bool"] = "true"; + BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); + + params["bool"] = 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"] = false; + BOOST_TEST( (params.get("bool") && *params.get("bool") == false) ); + + params["bool"] = "false"; + BOOST_TEST( (params.get("bool") && *params.get("bool") == false) ); + + params["bool"] = 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)); + + return ::boost::report_errors(); +} diff --git a/tests/python_tests/parameters_test.py b/tests/python_tests/parameters_test.py index f4a774df9..7fcb483fb 100644 --- a/tests/python_tests/parameters_test.py +++ b/tests/python_tests/parameters_test.py @@ -24,6 +24,11 @@ def test_parameter(): eq_(p[0],'float') eq_(p[1],1.0777) + p = mapnik.Parameter('bool_string','True') + eq_(p[0],'bool_string') + eq_(p[1],'True') + eq_(bool(p[1]),True) + def test_parameters(): params = mapnik.Parameters()