add new unit test SprixelMaximize #1658

This commit is contained in:
nick black 2021-05-16 06:57:48 -04:00 committed by Nick Black
parent 935d2dbe28
commit 194c739038

View File

@ -22,7 +22,7 @@ TEST_CASE("Bitmaps") {
CHECK(nc_->tcache.bitmap_supported); CHECK(nc_->tcache.bitmap_supported);
} }
SUBCASE("SprixelResize") { SUBCASE("SprixelMinimize") {
auto y = 10; auto y = 10;
auto x = 10; auto x = 10;
std::vector<uint32_t> v(x * y, htole(0xe61c28ff)); std::vector<uint32_t> v(x * y, htole(0xe61c28ff));
@ -46,6 +46,34 @@ TEST_CASE("Bitmaps") {
ncvisual_destroy(ncv); ncvisual_destroy(ncv);
} }
SUBCASE("SprixelMaximize") {
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 = n_,
.scaling = NCSCALE_NONE,
.y = 0, .x = 0,
.begy = 0, .begx = 0,
.leny = 0, .lenx = 0,
.blitter = NCBLIT_PIXEL,
.flags = NCVISUAL_OPTION_NODEGRADE,
.transcolor = 0,
};
int maxy, maxx;
ncplane_pixelgeom(n_, nullptr, nullptr, nullptr, nullptr, &maxy, &maxx);
CHECK(0 == ncvisual_resize(ncv, maxy, maxx));
auto n = ncvisual_render(nc_, ncv, &vopts);
REQUIRE(n_ == n);
auto s = n->sprite;
REQUIRE(nullptr != s);
CHECK(0 == notcurses_render(nc_));
ncvisual_destroy(ncv);
ncplane_erase(n);
}
// a sprixel requires a plane large enough to hold it // a sprixel requires a plane large enough to hold it
SUBCASE("SprixelTooTall") { SUBCASE("SprixelTooTall") {
auto y = nc_->tcache.cellpixy + 6; auto y = nc_->tcache.cellpixy + 6;