[stacking] guard tests for quadrants

pull/1520/head
nick black 3 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
SUBCASE("QuadblitterMax") {
if(notcurses_canutf8(nc_)){
uint32_t p2x2[4];
uint32_t* ptl = &p2x2[0];
ncpixel_set_a(ptl, 0xff);
ncpixel_set_r(ptl, 0);
ncpixel_set_g(ptl, 0);
ncpixel_set_b(ptl, 0);
uint32_t* ptr = &p2x2[1];
ncpixel_set_a(ptr, 0xff);
ncpixel_set_r(ptr, 0x43);
ncpixel_set_g(ptr, 0x46);
ncpixel_set_b(ptr, 0x43);
uint32_t* pbl = &p2x2[2];
ncpixel_set_a(pbl, 0xff);
ncpixel_set_r(pbl, 0x4c);
ncpixel_set_g(pbl, 0x50);
ncpixel_set_b(pbl, 0x51);
uint32_t* pbr = &p2x2[3];
ncpixel_set_a(pbr, 0xff);
ncpixel_set_r(pbr, 0x90);
ncpixel_set_g(pbr, 0x94);
ncpixel_set_b(pbr, 0x95);
auto ncv = ncvisual_from_rgba(p2x2, 2, 8, 2);
REQUIRE(nullptr != ncv);
struct ncvisual_options vopts = {
.n = nullptr, .scaling = NCSCALE_NONE,
.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);
REQUIRE(nullptr != ncp);
CHECK(0 == notcurses_render(nc_));
ncplane_destroy(ncp);
uint64_t channels;
uint16_t stylemask;
auto egc = notcurses_at_yx(nc_, 0, 0, &stylemask, &channels);
REQUIRE(nullptr != egc);
CHECK(0 == strcmp(egc, ""));
CHECK(0 == stylemask);
CHECK(0x4060646340000000 == channels);
free(egc);
if(nc_->tcache.quadrants){
uint32_t p2x2[4];
uint32_t* ptl = &p2x2[0];
ncpixel_set_a(ptl, 0xff);
ncpixel_set_r(ptl, 0);
ncpixel_set_g(ptl, 0);
ncpixel_set_b(ptl, 0);
uint32_t* ptr = &p2x2[1];
ncpixel_set_a(ptr, 0xff);
ncpixel_set_r(ptr, 0x43);
ncpixel_set_g(ptr, 0x46);
ncpixel_set_b(ptr, 0x43);
uint32_t* pbl = &p2x2[2];
ncpixel_set_a(pbl, 0xff);
ncpixel_set_r(pbl, 0x4c);
ncpixel_set_g(pbl, 0x50);
ncpixel_set_b(pbl, 0x51);
uint32_t* pbr = &p2x2[3];
ncpixel_set_a(pbr, 0xff);
ncpixel_set_r(pbr, 0x90);
ncpixel_set_g(pbr, 0x94);
ncpixel_set_b(pbr, 0x95);
auto ncv = ncvisual_from_rgba(p2x2, 2, 8, 2);
REQUIRE(nullptr != ncv);
struct ncvisual_options vopts = {
.n = nullptr, .scaling = NCSCALE_NONE,
.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);
REQUIRE(nullptr != ncp);
CHECK(0 == notcurses_render(nc_));
ncplane_destroy(ncp);
uint64_t channels;
uint16_t stylemask;
auto egc = notcurses_at_yx(nc_, 0, 0, &stylemask, &channels);
REQUIRE(nullptr != egc);
CHECK(0 == strcmp(egc, ""));
CHECK(0 == stylemask);
CHECK(0x4060646340000000 == channels);
free(egc);
}
}
}

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

Loading…
Cancel
Save