unit test for visuals with partial limit + offset #1661

pull/1683/head
nick black 3 years ago committed by Nick Black
parent 69adacf3f5
commit a0bf28645f

@ -35,7 +35,7 @@ TEST_CASE("Visual") {
CHECK(0 == ncplane_destroy(n));
}
// check that leny/lenx properly limit the output
// check that leny/lenx properly limit the output, new plane
SUBCASE("Partial") {
auto y = 10;
auto x = 10;
@ -59,6 +59,32 @@ TEST_CASE("Visual") {
CHECK(0 == ncplane_destroy(n));
}
// partial limit via len, offset via y/x, new plane
SUBCASE("PartialOffset") {
auto y = 10;
auto x = 10;
std::vector<uint32_t> v(x * y, htole(0xe61c28ff));
auto ncv = ncvisual_from_rgba(v.data(), y, sizeof(decltype(v)::value_type) * x, x);
REQUIRE(nullptr != ncv);
struct ncvisual_options vopts = {
.n = nullptr,
.scaling = NCSCALE_NONE,
.y = 2, .x = 4,
.begy = 0, .begx = 0,
.leny = 5, .lenx = 8,
.blitter = NCBLIT_1x1,
.flags = 0, .transcolor = 0,
};
auto n = ncvisual_render(nc_, ncv, &vopts);
REQUIRE(nullptr != n);
CHECK(5 == ncplane_dim_y(n));
CHECK(8 == ncplane_dim_x(n));
CHECK(2 == ncplane_y(n));
CHECK(4 == ncplane_x(n));
ncvisual_destroy(ncv);
CHECK(0 == ncplane_destroy(n));
}
SUBCASE("InflateBitmap") {
const uint32_t pixels[4] = { htole(0xffff00ff), htole(0xff00ffff), htole(0xff0000ff), htole(0xffffffff) };
auto ncv = ncvisual_from_rgba(pixels, 2, 8, 2);

Loading…
Cancel
Save