2016-03-03 18:53:58 +00:00
|
|
|
|
2015-05-10 19:28:10 +00:00
|
|
|
#include "catch.hpp"
|
|
|
|
|
|
|
|
// mapnik
|
|
|
|
#include <mapnik/image_any.hpp>
|
|
|
|
#include <mapnik/image_view_any.hpp>
|
|
|
|
#include <mapnik/color.hpp>
|
|
|
|
#include <mapnik/image_util.hpp>
|
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
TEST_CASE("image is_solid")
|
|
|
|
{
|
|
|
|
SECTION("test rgba8")
|
|
|
|
{
|
|
|
|
mapnik::image_rgba8 im(4, 4);
|
|
|
|
mapnik::image_any im_any(mapnik::image_rgba8(4, 4));
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
CHECK(mapnik::is_solid(im));
|
|
|
|
CHECK(mapnik::is_solid(im_any));
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
mapnik::image_view_rgba8 im_view(0, 0, 4, 4, im);
|
|
|
|
mapnik::image_view_any im_view_any(mapnik::image_view_rgba8(0, 0, 4, 4, im));
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
CHECK(mapnik::is_solid(im_view));
|
|
|
|
CHECK(mapnik::is_solid(im_view_any));
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
mapnik::color c1("green");
|
|
|
|
mapnik::color c2("blue");
|
|
|
|
mapnik::fill(im, c1);
|
|
|
|
mapnik::fill(im_any, c1);
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
CHECK(mapnik::is_solid(im));
|
|
|
|
CHECK(mapnik::is_solid(im_any));
|
|
|
|
CHECK(mapnik::is_solid(im_view));
|
|
|
|
CHECK(mapnik::is_solid(im_view_any));
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
mapnik::set_pixel(im, 0, 0, c2);
|
|
|
|
mapnik::set_pixel(im_any, 0, 0, c2);
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
CHECK_FALSE(mapnik::is_solid(im));
|
|
|
|
CHECK_FALSE(mapnik::is_solid(im_any));
|
|
|
|
CHECK_FALSE(mapnik::is_solid(im_view));
|
|
|
|
CHECK_FALSE(mapnik::is_solid(im_view_any));
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
} // END SECTION
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
SECTION("test gray8")
|
|
|
|
{
|
|
|
|
mapnik::image_gray8 im(4, 4);
|
|
|
|
mapnik::image_any im_any(mapnik::image_gray8(4, 4));
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
CHECK(mapnik::is_solid(im));
|
|
|
|
CHECK(mapnik::is_solid(im_any));
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
mapnik::image_view_gray8 im_view(0, 0, 4, 4, im);
|
|
|
|
mapnik::image_view_any im_view_any(mapnik::image_view_gray8(0, 0, 4, 4, im));
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
CHECK(mapnik::is_solid(im_view));
|
|
|
|
CHECK(mapnik::is_solid(im_view_any));
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
mapnik::fill(im, 1);
|
|
|
|
mapnik::fill(im_any, 1);
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
CHECK(mapnik::is_solid(im));
|
|
|
|
CHECK(mapnik::is_solid(im_any));
|
|
|
|
CHECK(mapnik::is_solid(im_view));
|
|
|
|
CHECK(mapnik::is_solid(im_view_any));
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
mapnik::set_pixel(im, 0, 0, 2);
|
|
|
|
mapnik::set_pixel(im_any, 0, 0, 2);
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
CHECK_FALSE(mapnik::is_solid(im));
|
|
|
|
CHECK_FALSE(mapnik::is_solid(im_any));
|
|
|
|
CHECK_FALSE(mapnik::is_solid(im_view));
|
|
|
|
CHECK_FALSE(mapnik::is_solid(im_view_any));
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
} // END SECTION
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
SECTION("test image null")
|
|
|
|
{
|
|
|
|
mapnik::image_null im;
|
|
|
|
mapnik::image_any im_any;
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
CHECK(mapnik::is_solid(im));
|
|
|
|
CHECK(mapnik::is_solid(im_any));
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
mapnik::image_view_null im_view;
|
|
|
|
mapnik::image_view_any im_view_any;
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
CHECK(mapnik::is_solid(im_view));
|
|
|
|
CHECK(mapnik::is_solid(im_view_any));
|
2015-05-10 19:28:10 +00:00
|
|
|
|
2022-01-26 22:25:53 +00:00
|
|
|
} // END SECTION
|
2015-05-10 19:28:10 +00:00
|
|
|
|
|
|
|
} // END TEST CASE
|