C++ test cleanup
This commit is contained in:
parent
a6978cb375
commit
1b35d5a31b
12 changed files with 258 additions and 215 deletions
|
@ -144,64 +144,72 @@ int main(int argc, char** argv)
|
|||
using source_over_old_agg = agg::comp_op_rgba_src_over2<color, agg::order_rgba>;
|
||||
using source_over = agg::comp_op_rgba_src_over<color, agg::order_rgba>;
|
||||
|
||||
color white(255,255,255,255);
|
||||
color black(0,0,0,255);
|
||||
|
||||
BOOST_TEST_EQ( to_string(blend<source_over>(white,white)), to_string(white) );
|
||||
BOOST_TEST_EQ( to_string(blend<source_over>(white,black)), to_string(white) );
|
||||
BOOST_TEST_EQ( to_string(blend<source_over>(black,white)), to_string(black) );
|
||||
|
||||
// https://github.com/mapnik/mapnik/issues/1452#issuecomment-8154646
|
||||
color near_white(254,254,254,254); // Source
|
||||
color near_trans(1,1,1,1); // Dest
|
||||
color expected_color(252,252,252,255); // expected result
|
||||
BOOST_TEST_EQ( to_string(blend<source_over_old_agg>(near_white,near_trans)), to_string(color(252,252,252,254)) );
|
||||
BOOST_TEST_EQ( to_string(blend<source_over>(near_white,near_trans)), to_string(expected_color) );
|
||||
BOOST_TEST_EQ( to_string(normal_blend(near_white,near_trans)), to_string(expected_color) );
|
||||
|
||||
// using normal_blend as expected, compare a variety of other colors
|
||||
|
||||
try
|
||||
{
|
||||
color source(128,128,128,255);
|
||||
color dest(128,128,128,255);
|
||||
unsigned cover = 128;
|
||||
std::string expected_str = to_string(normal_blend(source,dest,cover));
|
||||
BOOST_TEST_EQ( to_string(blend<source_over>(source,dest,cover)), expected_str );
|
||||
BOOST_TEST_EQ( to_string(blend<source_over_old_agg>(source,dest,cover)), expected_str );
|
||||
}
|
||||
color white(255,255,255,255);
|
||||
color black(0,0,0,255);
|
||||
|
||||
BOOST_TEST_EQ( to_string(blend<source_over>(white,white)), to_string(white) );
|
||||
BOOST_TEST_EQ( to_string(blend<source_over>(white,black)), to_string(white) );
|
||||
BOOST_TEST_EQ( to_string(blend<source_over>(black,white)), to_string(black) );
|
||||
|
||||
// https://github.com/mapnik/mapnik/issues/1452#issuecomment-8154646
|
||||
color near_white(254,254,254,254); // Source
|
||||
color near_trans(1,1,1,1); // Dest
|
||||
color expected_color(252,252,252,255); // expected result
|
||||
BOOST_TEST_EQ( to_string(blend<source_over_old_agg>(near_white,near_trans)), to_string(color(252,252,252,254)) );
|
||||
BOOST_TEST_EQ( to_string(blend<source_over>(near_white,near_trans)), to_string(expected_color) );
|
||||
BOOST_TEST_EQ( to_string(normal_blend(near_white,near_trans)), to_string(expected_color) );
|
||||
|
||||
// using normal_blend as expected, compare a variety of other colors
|
||||
|
||||
{
|
||||
color source(128,128,128,255);
|
||||
color dest(128,128,128,255);
|
||||
unsigned cover = 128;
|
||||
std::string expected_str = to_string(normal_blend(source,dest,cover));
|
||||
BOOST_TEST_EQ( to_string(blend<source_over>(source,dest,cover)), expected_str );
|
||||
BOOST_TEST_EQ( to_string(blend<source_over_old_agg>(source,dest,cover)), expected_str );
|
||||
}
|
||||
|
||||
{
|
||||
color source(128,128,128,255);
|
||||
color dest(128,128,128,255);
|
||||
unsigned cover = 245;
|
||||
std::string expected_str = to_string(normal_blend(source,dest,cover));
|
||||
BOOST_TEST_EQ( to_string(blend<source_over>(source,dest,cover)), expected_str );
|
||||
BOOST_TEST_EQ( to_string(blend<source_over_old_agg>(source,dest,cover)), expected_str );
|
||||
}
|
||||
|
||||
// commenting until I study these failures more (dane)
|
||||
/*
|
||||
{
|
||||
// fails, why?
|
||||
color source(127,127,127,127);
|
||||
color dest(127,127,127,127);
|
||||
unsigned cover = 255;
|
||||
std::string expected_str = to_string(normal_blend(source,dest,cover));
|
||||
BOOST_TEST_EQ( to_string(blend<source_over>(source,dest,cover)), expected_str );
|
||||
BOOST_TEST_EQ( to_string(blend<source_over_old_agg>(source,dest,cover)), expected_str );
|
||||
}
|
||||
|
||||
{
|
||||
// fails, why?
|
||||
color source(128,128,128,128);
|
||||
color dest(128,128,128,128);
|
||||
unsigned cover = 128;
|
||||
std::string expected_str = to_string(normal_blend(source,dest,cover));
|
||||
BOOST_TEST_EQ( to_string(blend<source_over>(source,dest,cover)), expected_str );
|
||||
BOOST_TEST_EQ( to_string(blend<source_over_old_agg>(source,dest,cover)), expected_str );
|
||||
}
|
||||
*/
|
||||
}
|
||||
catch (std::exception const & ex)
|
||||
{
|
||||
color source(128,128,128,255);
|
||||
color dest(128,128,128,255);
|
||||
unsigned cover = 245;
|
||||
std::string expected_str = to_string(normal_blend(source,dest,cover));
|
||||
BOOST_TEST_EQ( to_string(blend<source_over>(source,dest,cover)), expected_str );
|
||||
BOOST_TEST_EQ( to_string(blend<source_over_old_agg>(source,dest,cover)), expected_str );
|
||||
std::clog << ex.what() << "\n";
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
// commenting until I study these failures more (dane)
|
||||
/*
|
||||
{
|
||||
// fails, why?
|
||||
color source(127,127,127,127);
|
||||
color dest(127,127,127,127);
|
||||
unsigned cover = 255;
|
||||
std::string expected_str = to_string(normal_blend(source,dest,cover));
|
||||
BOOST_TEST_EQ( to_string(blend<source_over>(source,dest,cover)), expected_str );
|
||||
BOOST_TEST_EQ( to_string(blend<source_over_old_agg>(source,dest,cover)), expected_str );
|
||||
}
|
||||
|
||||
{
|
||||
// fails, why?
|
||||
color source(128,128,128,128);
|
||||
color dest(128,128,128,128);
|
||||
unsigned cover = 128;
|
||||
std::string expected_str = to_string(normal_blend(source,dest,cover));
|
||||
BOOST_TEST_EQ( to_string(blend<source_over>(source,dest,cover)), expected_str );
|
||||
BOOST_TEST_EQ( to_string(blend<source_over_old_agg>(source,dest,cover)), expected_str );
|
||||
}
|
||||
*/
|
||||
|
||||
if (!::boost::detail::test_errors()) {
|
||||
if (quiet) std::clog << "\x1b[1;32m.\x1b[0m";
|
||||
else std::clog << "C++ AGG blending: \x1b[1;32m✓ \x1b[0m\n";
|
||||
|
|
|
@ -295,7 +295,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
catch (std::exception const & ex)
|
||||
{
|
||||
std::clog << "C++ type conversions problem: " << ex.what() << "\n";
|
||||
std::clog << ex.what() << "\n";
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,58 +18,66 @@ int main(int argc, char** argv)
|
|||
}
|
||||
bool quiet = std::find(args.begin(), args.end(), "-q")!=args.end();
|
||||
|
||||
mapnik::Map m0(100,100);
|
||||
mapnik::Map m2(200,100);
|
||||
try
|
||||
{
|
||||
mapnik::Map m0(100,100);
|
||||
mapnik::Map m2(200,100);
|
||||
|
||||
// mapnik::datasource
|
||||
mapnik::datasource_cache::instance().register_datasources("plugins/input/shape.input");
|
||||
mapnik::parameters p;
|
||||
p["type"]="shape";
|
||||
p["file"]="demo/data/boundaries";
|
||||
p["encoding"]="latin1";
|
||||
auto ds0 = mapnik::datasource_cache::instance().create(p);
|
||||
// mapnik::datasource
|
||||
mapnik::datasource_cache::instance().register_datasources("plugins/input/shape.input");
|
||||
mapnik::parameters p;
|
||||
p["type"]="shape";
|
||||
p["file"]="demo/data/boundaries";
|
||||
p["encoding"]="latin1";
|
||||
auto ds0 = mapnik::datasource_cache::instance().create(p);
|
||||
|
||||
auto ds1 = ds0; // shared ptr copy
|
||||
BOOST_TEST(ds1 == ds0);
|
||||
BOOST_TEST(*ds1 == *ds0);
|
||||
ds1 = mapnik::datasource_cache::instance().create(p); // new with the same parameters
|
||||
BOOST_TEST(ds1 != ds0);
|
||||
BOOST_TEST(*ds1 == *ds0);
|
||||
auto ds2 = std::move(ds1);
|
||||
BOOST_TEST(ds2 != ds0);
|
||||
BOOST_TEST(*ds2 == *ds0);
|
||||
auto ds1 = ds0; // shared ptr copy
|
||||
BOOST_TEST(ds1 == ds0);
|
||||
BOOST_TEST(*ds1 == *ds0);
|
||||
ds1 = mapnik::datasource_cache::instance().create(p); // new with the same parameters
|
||||
BOOST_TEST(ds1 != ds0);
|
||||
BOOST_TEST(*ds1 == *ds0);
|
||||
auto ds2 = std::move(ds1);
|
||||
BOOST_TEST(ds2 != ds0);
|
||||
BOOST_TEST(*ds2 == *ds0);
|
||||
|
||||
// mapnik::layer
|
||||
mapnik::layer l0("test-layer");
|
||||
l0.set_datasource(ds0);
|
||||
// mapnik::layer
|
||||
mapnik::layer l0("test-layer");
|
||||
l0.set_datasource(ds0);
|
||||
|
||||
mapnik::layer l1 = l0; // copy assignment
|
||||
BOOST_TEST(l1 == l0);
|
||||
mapnik::layer l2(l0); // copy ctor
|
||||
BOOST_TEST(l2 == l0);
|
||||
mapnik::layer l3(mapnik::layer("test-layer")); // move ctor
|
||||
l3.set_datasource(ds2);
|
||||
mapnik::layer l1 = l0; // copy assignment
|
||||
BOOST_TEST(l1 == l0);
|
||||
mapnik::layer l2(l0); // copy ctor
|
||||
BOOST_TEST(l2 == l0);
|
||||
mapnik::layer l3(mapnik::layer("test-layer")); // move ctor
|
||||
l3.set_datasource(ds2);
|
||||
|
||||
BOOST_TEST(l3 == l0);
|
||||
mapnik::layer l4 = std::move(l3);
|
||||
BOOST_TEST(l4 == l0); // move assignment
|
||||
BOOST_TEST(l3 == l0);
|
||||
mapnik::layer l4 = std::move(l3);
|
||||
BOOST_TEST(l4 == l0); // move assignment
|
||||
|
||||
m0.add_layer(l4);
|
||||
m0.set_background(mapnik::color("skyblue"));
|
||||
m2.set_background(mapnik::color("skyblue"));
|
||||
m0.add_layer(l4);
|
||||
m0.set_background(mapnik::color("skyblue"));
|
||||
m2.set_background(mapnik::color("skyblue"));
|
||||
|
||||
auto m1 = m0; //copy
|
||||
auto m1 = m0; //copy
|
||||
|
||||
BOOST_TEST(m0 == m1);
|
||||
BOOST_TEST(m0 != m2);
|
||||
BOOST_TEST(m0 == m1);
|
||||
BOOST_TEST(m0 != m2);
|
||||
|
||||
m2 = m1; // copy
|
||||
BOOST_TEST(m2 == m1);
|
||||
m2 = std::move(m1);
|
||||
BOOST_TEST(m2 == m0);
|
||||
BOOST_TEST(m1 != m0);
|
||||
m2 = m1; // copy
|
||||
BOOST_TEST(m2 == m1);
|
||||
m2 = std::move(m1);
|
||||
BOOST_TEST(m2 == m0);
|
||||
BOOST_TEST(m1 != m0);
|
||||
|
||||
BOOST_TEST(m0 == m2);
|
||||
BOOST_TEST(m0 == m2);
|
||||
}
|
||||
catch (std::exception const & ex)
|
||||
{
|
||||
std::clog << ex.what() << "\n";
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
if (!::boost::detail::test_errors())
|
||||
{
|
||||
|
|
|
@ -193,7 +193,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
catch (std::exception const & ex)
|
||||
{
|
||||
std::clog << "C++ fonts registration problem: " << ex.what() << "\n";
|
||||
std::clog << ex.what() << "\n";
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -143,43 +143,52 @@ int main(int argc, char** argv)
|
|||
|
||||
BOOST_TEST(set_working_dir(args));
|
||||
|
||||
// LineString/bbox clipping
|
||||
try
|
||||
{
|
||||
std::string wkt_in("LineString(0 0,200 200)");
|
||||
boost::optional<std::string> result = linestring_bbox_clipping(mapnik::box2d<double>(50,50,150,150),wkt_in);
|
||||
BOOST_TEST(result);
|
||||
BOOST_TEST_EQ(*result,std::string("LineString(50 50,150 150)"));
|
||||
// LineString/bbox clipping
|
||||
{
|
||||
std::string wkt_in("LineString(0 0,200 200)");
|
||||
boost::optional<std::string> result = linestring_bbox_clipping(mapnik::box2d<double>(50,50,150,150),wkt_in);
|
||||
BOOST_TEST(result);
|
||||
BOOST_TEST_EQ(*result,std::string("LineString(50 50,150 150)"));
|
||||
}
|
||||
// Polygon/bbox clipping
|
||||
#if 0
|
||||
// these tests will fail
|
||||
{
|
||||
std::string wkt_in("Polygon((50 50,150 50,150 150,50 150,50 50))");
|
||||
boost::optional<std::string> result = polygon_bbox_clipping(mapnik::box2d<double>(50,50,150,150),wkt_in);
|
||||
BOOST_TEST(result);
|
||||
BOOST_TEST_EQ(*result,std::string("Polygon((50 50,150 50,150 150,50 150,50 50))"));
|
||||
}
|
||||
|
||||
{
|
||||
std::string wkt_in("Polygon((60 60,140 60,140 160,60 140,60 60))");
|
||||
boost::optional<std::string> result = polygon_bbox_clipping(mapnik::box2d<double>(50,50,150,150),wkt_in);
|
||||
BOOST_TEST(result);
|
||||
BOOST_TEST_EQ(*result,std::string("Polygon((60 60,140 60,140 160,60 140,60 60))"));
|
||||
}
|
||||
|
||||
{
|
||||
std::string wkt_in("Polygon((0 0,10 0,10 10,0 10,0 0))");
|
||||
boost::optional<std::string> result = polygon_bbox_clipping(mapnik::box2d<double>(50,50,150,150),wkt_in);
|
||||
BOOST_TEST(result);
|
||||
BOOST_TEST_EQ(*result, std::string("GeometryCollection EMPTY"));
|
||||
}
|
||||
{
|
||||
std::string wkt_in("Polygon((0 0,100 200,200 0,0 0 ))");
|
||||
boost::optional<std::string> result = polygon_bbox_clipping(mapnik::box2d<double>(50,50,150,150),wkt_in);
|
||||
BOOST_TEST(result);
|
||||
BOOST_TEST_EQ(*result,std::string("Polygon((50 50,50 100,75 150,125 150,150 100,150 50,50 50))"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// Polygon/bbox clipping
|
||||
#if 0
|
||||
// these tests will fail
|
||||
catch (std::exception const & ex)
|
||||
{
|
||||
std::string wkt_in("Polygon((50 50,150 50,150 150,50 150,50 50))");
|
||||
boost::optional<std::string> result = polygon_bbox_clipping(mapnik::box2d<double>(50,50,150,150),wkt_in);
|
||||
BOOST_TEST(result);
|
||||
BOOST_TEST_EQ(*result,std::string("Polygon((50 50,150 50,150 150,50 150,50 50))"));
|
||||
std::clog << ex.what() << "\n";
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
{
|
||||
std::string wkt_in("Polygon((60 60,140 60,140 160,60 140,60 60))");
|
||||
boost::optional<std::string> result = polygon_bbox_clipping(mapnik::box2d<double>(50,50,150,150),wkt_in);
|
||||
BOOST_TEST(result);
|
||||
BOOST_TEST_EQ(*result,std::string("Polygon((60 60,140 60,140 160,60 140,60 60))"));
|
||||
}
|
||||
|
||||
{
|
||||
std::string wkt_in("Polygon((0 0,10 0,10 10,0 10,0 0))");
|
||||
boost::optional<std::string> result = polygon_bbox_clipping(mapnik::box2d<double>(50,50,150,150),wkt_in);
|
||||
BOOST_TEST(result);
|
||||
BOOST_TEST_EQ(*result, std::string("GeometryCollection EMPTY"));
|
||||
}
|
||||
{
|
||||
std::string wkt_in("Polygon((0 0,100 200,200 0,0 0 ))");
|
||||
boost::optional<std::string> result = polygon_bbox_clipping(mapnik::box2d<double>(50,50,150,150),wkt_in);
|
||||
BOOST_TEST(result);
|
||||
BOOST_TEST_EQ(*result,std::string("Polygon((50 50,50 100,75 150,125 150,150 100,150 50,50 50))"));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!::boost::detail::test_errors())
|
||||
{
|
||||
|
|
|
@ -110,7 +110,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
catch (std::exception const & ex)
|
||||
{
|
||||
std::clog << "C++ image i/o problem: " << ex.what() << "\n";
|
||||
std::clog << ex.what() << "\n";
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
catch (std::exception const & ex)
|
||||
{
|
||||
std::clog << "C++ image painted problem: " << ex.what() << std::endl;
|
||||
std::clog << ex.what() << std::endl;
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,45 +14,53 @@ int main(int argc, char** argv)
|
|||
}
|
||||
bool quiet = std::find(args.begin(), args.end(), "-q")!=args.end();
|
||||
|
||||
// reused these for simplicity
|
||||
double x,y;
|
||||
try
|
||||
{
|
||||
// reused these for simplicity
|
||||
double x,y;
|
||||
|
||||
// single point
|
||||
mapnik::geometry_type pt(mapnik::geometry_type::types::Point);
|
||||
pt.move_to(10,10);
|
||||
BOOST_TEST( mapnik::label::centroid(pt, x, y) );
|
||||
BOOST_TEST( x == 10 );
|
||||
BOOST_TEST( y == 10 );
|
||||
// single point
|
||||
mapnik::geometry_type pt(mapnik::geometry_type::types::Point);
|
||||
pt.move_to(10,10);
|
||||
BOOST_TEST( mapnik::label::centroid(pt, x, y) );
|
||||
BOOST_TEST( x == 10 );
|
||||
BOOST_TEST( y == 10 );
|
||||
|
||||
// two points
|
||||
pt.move_to(20,20);
|
||||
BOOST_TEST( mapnik::label::centroid(pt, x, y) );
|
||||
BOOST_TEST_EQ( x, 15 );
|
||||
BOOST_TEST_EQ( y, 15 );
|
||||
// two points
|
||||
pt.move_to(20,20);
|
||||
BOOST_TEST( mapnik::label::centroid(pt, x, y) );
|
||||
BOOST_TEST_EQ( x, 15 );
|
||||
BOOST_TEST_EQ( y, 15 );
|
||||
|
||||
// line with two verticies
|
||||
mapnik::geometry_type line(mapnik::geometry_type::types::LineString);
|
||||
line.move_to(0,0);
|
||||
line.line_to(50,50);
|
||||
BOOST_TEST( mapnik::label::centroid(line, x, y) );
|
||||
BOOST_TEST( x == 25 );
|
||||
BOOST_TEST( y == 25 );
|
||||
// line with two verticies
|
||||
mapnik::geometry_type line(mapnik::geometry_type::types::LineString);
|
||||
line.move_to(0,0);
|
||||
line.line_to(50,50);
|
||||
BOOST_TEST( mapnik::label::centroid(line, x, y) );
|
||||
BOOST_TEST( x == 25 );
|
||||
BOOST_TEST( y == 25 );
|
||||
|
||||
// TODO - centroid and interior should be equal but they appear not to be (check largest)
|
||||
// MULTIPOLYGON(((-52 40,-60 32,-68 40,-60 48,-52 40)),((-60 50,-80 30,-100 49.9999999999999,-80.0000000000001 70,-60 50)),((-52 60,-60 52,-68 60,-60 68,-52 60)))
|
||||
// TODO - centroid and interior should be equal but they appear not to be (check largest)
|
||||
// MULTIPOLYGON(((-52 40,-60 32,-68 40,-60 48,-52 40)),((-60 50,-80 30,-100 49.9999999999999,-80.0000000000001 70,-60 50)),((-52 60,-60 52,-68 60,-60 68,-52 60)))
|
||||
|
||||
// hit tests
|
||||
mapnik::geometry_type pt_hit(mapnik::geometry_type::types::Point);
|
||||
pt_hit.move_to(10,10);
|
||||
BOOST_TEST( mapnik::label::hit_test(pt_hit, 10, 10, 0.1) );
|
||||
BOOST_TEST( !mapnik::label::hit_test(pt_hit, 9, 9, 0) );
|
||||
BOOST_TEST( mapnik::label::hit_test(pt_hit, 9, 9, 1.5) );
|
||||
mapnik::geometry_type line_hit(mapnik::geometry_type::types::LineString);
|
||||
line_hit.move_to(0,0);
|
||||
line_hit.line_to(50,50);
|
||||
BOOST_TEST( mapnik::label::hit_test(line_hit, 0, 0, 0.001) );
|
||||
BOOST_TEST( !mapnik::label::hit_test(line_hit, 1, 1, 0) );
|
||||
BOOST_TEST( mapnik::label::hit_test(line_hit, 1, 1, 1.001) );
|
||||
// hit tests
|
||||
mapnik::geometry_type pt_hit(mapnik::geometry_type::types::Point);
|
||||
pt_hit.move_to(10,10);
|
||||
BOOST_TEST( mapnik::label::hit_test(pt_hit, 10, 10, 0.1) );
|
||||
BOOST_TEST( !mapnik::label::hit_test(pt_hit, 9, 9, 0) );
|
||||
BOOST_TEST( mapnik::label::hit_test(pt_hit, 9, 9, 1.5) );
|
||||
mapnik::geometry_type line_hit(mapnik::geometry_type::types::LineString);
|
||||
line_hit.move_to(0,0);
|
||||
line_hit.line_to(50,50);
|
||||
BOOST_TEST( mapnik::label::hit_test(line_hit, 0, 0, 0.001) );
|
||||
BOOST_TEST( !mapnik::label::hit_test(line_hit, 1, 1, 0) );
|
||||
BOOST_TEST( mapnik::label::hit_test(line_hit, 1, 1, 1.001) );
|
||||
}
|
||||
catch (std::exception const & ex)
|
||||
{
|
||||
std::clog << ex.what() << "\n";
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
if (!::boost::detail::test_errors()) {
|
||||
if (quiet) std::clog << "\x1b[1;32m.\x1b[0m";
|
||||
|
|
|
@ -220,6 +220,7 @@ int main(int argc, char** argv)
|
|||
catch (std::exception const& ex)
|
||||
{
|
||||
std::cerr << ex.what() << "\n";
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
if (!::boost::detail::test_errors())
|
||||
|
|
|
@ -15,68 +15,76 @@ int main(int argc, char** argv)
|
|||
}
|
||||
bool quiet = std::find(args.begin(), args.end(), "-q")!=args.end();
|
||||
|
||||
mapnik::parameters params;
|
||||
try
|
||||
{
|
||||
mapnik::parameters params;
|
||||
|
||||
// true
|
||||
params["bool"] = mapnik::value_integer(true);
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == true));
|
||||
// true
|
||||
params["bool"] = mapnik::value_integer(true);
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == true));
|
||||
|
||||
params["bool"] = "true";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == true));
|
||||
params["bool"] = "true";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == true));
|
||||
|
||||
params["bool"] = mapnik::value_integer(1);
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == true));
|
||||
params["bool"] = mapnik::value_integer(1);
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == true));
|
||||
|
||||
params["bool"] = "1";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == true));
|
||||
params["bool"] = "1";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == true));
|
||||
|
||||
params["bool"] = "True";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == true));
|
||||
params["bool"] = "True";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == true));
|
||||
|
||||
params["bool"] = "on";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == true));
|
||||
params["bool"] = "on";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == true));
|
||||
|
||||
params["bool"] = "yes";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == true));
|
||||
params["bool"] = "yes";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == true));
|
||||
|
||||
// false
|
||||
params["bool"] = mapnik::value_integer(false);
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == false) );
|
||||
// false
|
||||
params["bool"] = mapnik::value_integer(false);
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == false) );
|
||||
|
||||
params["bool"] = "false";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == false) );
|
||||
params["bool"] = "false";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == false) );
|
||||
|
||||
params["bool"] = mapnik::value_integer(0);
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == false));
|
||||
params["bool"] = mapnik::value_integer(0);
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == false));
|
||||
|
||||
params["bool"] = "0";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == false));
|
||||
params["bool"] = "0";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == false));
|
||||
|
||||
params["bool"] = "False";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == false));
|
||||
params["bool"] = "False";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == false));
|
||||
|
||||
params["bool"] = "off";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == false));
|
||||
params["bool"] = "off";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == false));
|
||||
|
||||
params["bool"] = "no";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == false));
|
||||
params["bool"] = "no";
|
||||
BOOST_TEST( (params.get<mapnik::boolean_type>("bool") && *params.get<mapnik::boolean_type>("bool") == false));
|
||||
|
||||
// strings
|
||||
params["string"] = "hello";
|
||||
BOOST_TEST( (params.get<std::string>("string") && *params.get<std::string>("string") == "hello") );
|
||||
// strings
|
||||
params["string"] = "hello";
|
||||
BOOST_TEST( (params.get<std::string>("string") && *params.get<std::string>("string") == "hello") );
|
||||
|
||||
// int
|
||||
params["int"] = mapnik::value_integer(1);
|
||||
BOOST_TEST( (params.get<mapnik::value_integer>("int") && *params.get<mapnik::value_integer>("int") == 1) );
|
||||
// int
|
||||
params["int"] = mapnik::value_integer(1);
|
||||
BOOST_TEST( (params.get<mapnik::value_integer>("int") && *params.get<mapnik::value_integer>("int") == 1) );
|
||||
|
||||
// double
|
||||
params["double"] = 1.5;
|
||||
BOOST_TEST( (params.get<double>("double") && *params.get<double>("double") == 1.5) );
|
||||
// double
|
||||
params["double"] = 1.5;
|
||||
BOOST_TEST( (params.get<double>("double") && *params.get<double>("double") == 1.5) );
|
||||
|
||||
// value_null
|
||||
params["null"] = mapnik::value_null();
|
||||
// https://github.com/mapnik/mapnik/issues/2471
|
||||
//BOOST_TEST( (params.get<mapnik::value_null>("null") && *params.get<mapnik::value_null>("null") == mapnik::value_null()) );
|
||||
// value_null
|
||||
params["null"] = mapnik::value_null();
|
||||
// https://github.com/mapnik/mapnik/issues/2471
|
||||
//BOOST_TEST( (params.get<mapnik::value_null>("null") && *params.get<mapnik::value_null>("null") == mapnik::value_null()) );
|
||||
}
|
||||
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";
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "utils.hpp"
|
||||
|
||||
using namespace mapnik;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
@ -25,13 +23,16 @@ int main(int argc, char** argv)
|
|||
BOOST_TEST_EQ(sym.properties.count(keys::markers_multipolicy),static_cast<unsigned long>(1));
|
||||
marker_multi_policy_enum policy_out = get<mapnik::marker_multi_policy_enum>(sym, keys::markers_multipolicy);
|
||||
BOOST_TEST_EQ(policy_out,MARKER_WHOLE_MULTI);
|
||||
} catch (...) {
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
catch (std::exception const & ex)
|
||||
{
|
||||
std::clog << ex.what() << std::endl;
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
if (!::boost::detail::test_errors()) {
|
||||
if (quiet) std::clog << "\x1b[1;32m.\x1b[0m";
|
||||
else std::clog << "C++ exceptions: \x1b[1;32m✓ \x1b[0m\n";
|
||||
else std::clog << "C++ symbolizer test: \x1b[1;32m✓ \x1b[0m\n";
|
||||
::boost::detail::report_errors_remind().called_report_errors_function = true;
|
||||
} else {
|
||||
return ::boost::report_errors();
|
||||
|
|
|
@ -116,7 +116,7 @@ int main(int argc, char** argv)
|
|||
|
||||
if (!::boost::detail::test_errors()) {
|
||||
if (quiet) std::clog << "\x1b[1;32m.\x1b[0m";
|
||||
else std::clog << "C++ CSV parse: \x1b[1;32m✓ \x1b[0m\n";
|
||||
else std::clog << "C++ WKB formats test: \x1b[1;32m✓ \x1b[0m\n";
|
||||
::boost::detail::report_errors_remind().called_report_errors_function = true;
|
||||
} else {
|
||||
return ::boost::report_errors();
|
||||
|
|
Loading…
Reference in a new issue