add unit test for image::swap

This commit is contained in:
Mickey Rose 2016-09-07 19:23:36 +02:00
parent 4f008c6f2f
commit e25bc271ec

View file

@ -363,4 +363,30 @@ SECTION("Image copy/move")
}
}
SECTION("image::swap")
{
auto blue = mapnik::color(50, 50, 250).rgba();
auto orange = mapnik::color(250, 150, 0).rgba();
mapnik::image_rgba8 im;
mapnik::image_rgba8 im2(16, 16);
mapnik::image_rgba8 im3(16, 16);
im2.set(blue);
im3.set(orange);
// swap two non-empty images
CHECK_NOTHROW(im2.swap(im3));
CHECK(im2(0, 0) == orange);
CHECK(im3(0, 0) == blue);
// swap empty <-> non-empty
CHECK_NOTHROW(im.swap(im3));
CHECK(im3.data() == nullptr);
CHECKED_IF(im.data() != nullptr)
{
CHECK(im(0, 0) == blue);
}
}
} // END TEST CASE