[stacking] guard tests for quadrants

pull/1520/head
nick black 4 years ago
parent 1720457467
commit 1f67f540e6
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -111,47 +111,49 @@ TEST_CASE("Blitting") {
// original version https://github.com/dankamongmen/notcurses/issues/1354 // original version https://github.com/dankamongmen/notcurses/issues/1354
SUBCASE("QuadblitterMax") { SUBCASE("QuadblitterMax") {
if(notcurses_canutf8(nc_)){ if(notcurses_canutf8(nc_)){
uint32_t p2x2[4]; if(nc_->tcache.quadrants){
uint32_t* ptl = &p2x2[0]; uint32_t p2x2[4];
ncpixel_set_a(ptl, 0xff); uint32_t* ptl = &p2x2[0];
ncpixel_set_r(ptl, 0); ncpixel_set_a(ptl, 0xff);
ncpixel_set_g(ptl, 0); ncpixel_set_r(ptl, 0);
ncpixel_set_b(ptl, 0); ncpixel_set_g(ptl, 0);
uint32_t* ptr = &p2x2[1]; ncpixel_set_b(ptl, 0);
ncpixel_set_a(ptr, 0xff); uint32_t* ptr = &p2x2[1];
ncpixel_set_r(ptr, 0x43); ncpixel_set_a(ptr, 0xff);
ncpixel_set_g(ptr, 0x46); ncpixel_set_r(ptr, 0x43);
ncpixel_set_b(ptr, 0x43); ncpixel_set_g(ptr, 0x46);
uint32_t* pbl = &p2x2[2]; ncpixel_set_b(ptr, 0x43);
ncpixel_set_a(pbl, 0xff); uint32_t* pbl = &p2x2[2];
ncpixel_set_r(pbl, 0x4c); ncpixel_set_a(pbl, 0xff);
ncpixel_set_g(pbl, 0x50); ncpixel_set_r(pbl, 0x4c);
ncpixel_set_b(pbl, 0x51); ncpixel_set_g(pbl, 0x50);
uint32_t* pbr = &p2x2[3]; ncpixel_set_b(pbl, 0x51);
ncpixel_set_a(pbr, 0xff); uint32_t* pbr = &p2x2[3];
ncpixel_set_r(pbr, 0x90); ncpixel_set_a(pbr, 0xff);
ncpixel_set_g(pbr, 0x94); ncpixel_set_r(pbr, 0x90);
ncpixel_set_b(pbr, 0x95); ncpixel_set_g(pbr, 0x94);
auto ncv = ncvisual_from_rgba(p2x2, 2, 8, 2); ncpixel_set_b(pbr, 0x95);
REQUIRE(nullptr != ncv); auto ncv = ncvisual_from_rgba(p2x2, 2, 8, 2);
struct ncvisual_options vopts = { REQUIRE(nullptr != ncv);
.n = nullptr, .scaling = NCSCALE_NONE, struct ncvisual_options vopts = {
.y = 0, .x = 0, .begy = 0, .begx = 0, .leny = 0, .lenx = 0, .n = nullptr, .scaling = NCSCALE_NONE,
.blitter = NCBLIT_2x2, .flags = 0, .y = 0, .x = 0, .begy = 0, .begx = 0, .leny = 0, .lenx = 0,
}; .blitter = NCBLIT_2x2, .flags = 0,
auto ncp = ncvisual_render(nc_, ncv, &vopts); };
ncvisual_destroy(ncv); auto ncp = ncvisual_render(nc_, ncv, &vopts);
REQUIRE(nullptr != ncp); ncvisual_destroy(ncv);
CHECK(0 == notcurses_render(nc_)); REQUIRE(nullptr != ncp);
ncplane_destroy(ncp); CHECK(0 == notcurses_render(nc_));
uint64_t channels; ncplane_destroy(ncp);
uint16_t stylemask; uint64_t channels;
auto egc = notcurses_at_yx(nc_, 0, 0, &stylemask, &channels); uint16_t stylemask;
REQUIRE(nullptr != egc); auto egc = notcurses_at_yx(nc_, 0, 0, &stylemask, &channels);
CHECK(0 == strcmp(egc, "")); REQUIRE(nullptr != egc);
CHECK(0 == stylemask); CHECK(0 == strcmp(egc, ""));
CHECK(0x4060646340000000 == channels); CHECK(0 == stylemask);
free(egc); CHECK(0x4060646340000000 == channels);
free(egc);
}
} }
} }

@ -102,79 +102,83 @@ TEST_CASE("Stacking") {
} }
SUBCASE("StackedQuadHalves") { SUBCASE("StackedQuadHalves") {
struct ncplane_options opts = { if(nc_->tcache.quadrants){
0, 0, 1, 1, nullptr, "top", nullptr, 0, 0, 0, struct ncplane_options opts = {
}; 0, 0, 1, 1, nullptr, "top", nullptr, 0, 0, 0,
auto top = ncplane_create(n_, &opts); };
REQUIRE(nullptr != top); auto top = ncplane_create(n_, &opts);
// create an ncvisual of 2 rows, 2 columns, with the top 0xffffff REQUIRE(nullptr != top);
const uint32_t topv[] = {htole(0xff00ff00), htole(0xff00ff00), htole(0), htole(0)}; // create an ncvisual of 2 rows, 2 columns, with the top 0xffffff
auto ncv = ncvisual_from_rgba(topv, 2, 8, 2); const uint32_t topv[] = {htole(0xff00ff00), htole(0xff00ff00), htole(0), htole(0)};
REQUIRE(nullptr != ncv); auto ncv = ncvisual_from_rgba(topv, 2, 8, 2);
struct ncvisual_options vopts = { REQUIRE(nullptr != ncv);
.n = top, .scaling = NCSCALE_NONE, .y = 0, .x = 0, .begy = 0, .begx = 0, struct ncvisual_options vopts = {
.leny = 2, .lenx = 2, .blitter = NCBLIT_2x2, .flags = 0, .n = top, .scaling = NCSCALE_NONE, .y = 0, .x = 0, .begy = 0, .begx = 0,
}; .leny = 2, .lenx = 2, .blitter = NCBLIT_2x2, .flags = 0,
CHECK(top == ncvisual_render(nc_, ncv, &vopts)); };
ncvisual_destroy(ncv); CHECK(top == ncvisual_render(nc_, ncv, &vopts));
ncvisual_destroy(ncv);
// create an ncvisual of 2 rows, 2 columns, with the bottom 0xffffff // create an ncvisual of 2 rows, 2 columns, with the bottom 0xffffff
const uint32_t botv[] = {htole(0), htole(0), htole(0xff00ff00), htole(0xff00ff00)}; const uint32_t botv[] = {htole(0), htole(0), htole(0xff00ff00), htole(0xff00ff00)};
ncv = ncvisual_from_rgba(botv, 2, 8, 2); ncv = ncvisual_from_rgba(botv, 2, 8, 2);
REQUIRE(nullptr != ncv); REQUIRE(nullptr != ncv);
vopts.n = n_; vopts.n = n_;
CHECK(n_ == ncvisual_render(nc_, ncv, &vopts)); CHECK(n_ == ncvisual_render(nc_, ncv, &vopts));
ncvisual_destroy(ncv); ncvisual_destroy(ncv);
CHECK(0 == notcurses_render(nc_)); CHECK(0 == notcurses_render(nc_));
uint64_t channels; uint64_t channels;
auto egc = notcurses_at_yx(nc_, 0, 0, nullptr, &channels); auto egc = notcurses_at_yx(nc_, 0, 0, nullptr, &channels);
REQUIRE(nullptr != egc); REQUIRE(nullptr != egc);
// ought yield space with white background FIXME currently just yields // ought yield space with white background FIXME currently just yields
// an upper half block // an upper half block
CHECK(0 == strcmp("\u2580", egc)); CHECK(0 == strcmp("\u2580", egc));
CHECK(0x00ff00 == channels_fg_rgb(channels)); CHECK(0x00ff00 == channels_fg_rgb(channels));
CHECK(0x00ff00 == channels_bg_rgb(channels)); CHECK(0x00ff00 == channels_bg_rgb(channels));
ncplane_destroy(top); ncplane_destroy(top);
}
} }
SUBCASE("StackedQuadCrossed") { SUBCASE("StackedQuadCrossed") {
ncplane_erase(n_); if(nc_->tcache.quadrants){
notcurses_refresh(nc_, nullptr, nullptr); ncplane_erase(n_);
struct ncplane_options opts = { notcurses_refresh(nc_, nullptr, nullptr);
0, 0, 1, 1, nullptr, "top", nullptr, 0, 0, 0, struct ncplane_options opts = {
}; 0, 0, 1, 1, nullptr, "top", nullptr, 0, 0, 0,
auto top = ncplane_create(n_, &opts); };
REQUIRE(nullptr != top); auto top = ncplane_create(n_, &opts);
// create an ncvisual of 2 rows, 2 columns, with the tl, br 0xffffff REQUIRE(nullptr != top);
const uint32_t topv[] = {htole(0xffffffff), htole(0), htole(0), htole(0xffffffff)}; // create an ncvisual of 2 rows, 2 columns, with the tl, br 0xffffff
auto ncv = ncvisual_from_rgba(topv, 2, 8, 2); const uint32_t topv[] = {htole(0xffffffff), htole(0), htole(0), htole(0xffffffff)};
REQUIRE(nullptr != ncv); auto ncv = ncvisual_from_rgba(topv, 2, 8, 2);
struct ncvisual_options vopts = { REQUIRE(nullptr != ncv);
.n = top, .scaling = NCSCALE_NONE, .y = 0, .x = 0, .begy = 0, .begx = 0, struct ncvisual_options vopts = {
.leny = 2, .lenx = 2, .blitter = NCBLIT_2x2, .flags = 0, .n = top, .scaling = NCSCALE_NONE, .y = 0, .x = 0, .begy = 0, .begx = 0,
}; .leny = 2, .lenx = 2, .blitter = NCBLIT_2x2, .flags = 0,
CHECK(top == ncvisual_render(nc_, ncv, &vopts)); };
ncvisual_destroy(ncv); CHECK(top == ncvisual_render(nc_, ncv, &vopts));
ncvisual_destroy(ncv);
// create an ncvisual of 2 rows, 2 columns, with the tr, bl 0xffffff // create an ncvisual of 2 rows, 2 columns, with the tr, bl 0xffffff
const uint32_t botv[] = {htole(0), htole(0xffffffff), htole(0xffffffff), htole(0)}; const uint32_t botv[] = {htole(0), htole(0xffffffff), htole(0xffffffff), htole(0)};
ncv = ncvisual_from_rgba(botv, 2, 8, 2); ncv = ncvisual_from_rgba(botv, 2, 8, 2);
REQUIRE(nullptr != ncv); REQUIRE(nullptr != ncv);
vopts.n = n_; vopts.n = n_;
CHECK(n_ == ncvisual_render(nc_, ncv, &vopts)); CHECK(n_ == ncvisual_render(nc_, ncv, &vopts));
ncvisual_destroy(ncv); ncvisual_destroy(ncv);
CHECK(0 == notcurses_render(nc_)); CHECK(0 == notcurses_render(nc_));
uint64_t channels; uint64_t channels;
auto egc = notcurses_at_yx(nc_, 0, 0, nullptr, &channels); auto egc = notcurses_at_yx(nc_, 0, 0, nullptr, &channels);
REQUIRE(nullptr != egc); REQUIRE(nullptr != egc);
// ought yield space with white background FIXME currently just yields // ought yield space with white background FIXME currently just yields
// an upper half block // an upper half block
CHECK(0 == strcmp("\u259a", egc)); // quadrant upper left and lower right CHECK(0 == strcmp("\u259a", egc)); // quadrant upper left and lower right
CHECK(0xffffff == channels_fg_rgb(channels)); CHECK(0xffffff == channels_fg_rgb(channels));
CHECK(0xffffff == channels_bg_rgb(channels)); CHECK(0xffffff == channels_bg_rgb(channels));
ncplane_destroy(top); ncplane_destroy(top);
}
} }
// common teardown // common teardown

Loading…
Cancel
Save