Skip to content

Commit

Permalink
new unit test breaks #1068
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Feb 1, 2021
1 parent 4f7b32f commit 19a650e
Showing 1 changed file with 47 additions and 4 deletions.
51 changes: 47 additions & 4 deletions tests/stacking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,42 @@ TEST_CASE("Stacking") {
struct ncplane* n_ = notcurses_stddim_yx(nc_, &dimy, &dimx);
REQUIRE(nullptr != n_);

SUBCASE("LowerAtopUpperWhite") {
struct ncplane_options opts = {
0, 0, 1, 1, nullptr, "top", nullptr, 0,
};
auto top = ncplane_create(n_, &opts);
REQUIRE(nullptr != top);
// create an ncvisual of 2 rows, 1 column, with the bottom 0xffffff
const uint32_t topv[] = {htole(0), htole(0xffffffff)};
auto ncv = ncvisual_from_rgba(topv, 2, 4, 1);
REQUIRE(nullptr != ncv);
struct ncvisual_options vopts = {
.n = top, .scaling = NCSCALE_NONE, .y = 0, .x = 0, .begy = 0, .begx = 0,
.leny = 2, .lenx = 1, .blitter = NCBLIT_2x1, .flags = 0,
};
CHECK(top == ncvisual_render(nc_, ncv, &vopts));
ncvisual_destroy(ncv);

// create an ncvisual of 2 rows, 1 column, with the top 0xffffff
const uint32_t botv[] = {htole(0xffffffff), htole(0)};
ncv = ncvisual_from_rgba(botv, 2, 4, 1);
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
// a lower half block
CHECK(0 == strcmp("\u2584", egc));
CHECK(0xffffff == channels_fg_rgb(channels));
CHECK(0xffffff == channels_bg_rgb(channels));
ncplane_destroy(top);
}

SUBCASE("UpperAtopLowerWhite") {
struct ncplane_options opts = {
Expand Down Expand Up @@ -71,7 +107,7 @@ TEST_CASE("Stacking") {
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(0xffffffff), htole(0xffffffff), htole(0), htole(0)};
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 = {
Expand All @@ -82,7 +118,7 @@ TEST_CASE("Stacking") {
ncvisual_destroy(ncv);

// create an ncvisual of 2 rows, 2 columns, with the bottom 0xffffff
const uint32_t botv[] = {htole(0), htole(0), htole(0xffffffff), htole(0xffffffff)};
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_;
Expand All @@ -96,12 +132,14 @@ TEST_CASE("Stacking") {
// ought yield space with white background FIXME currently just yields
// an upper half block
CHECK(0 == strcmp("\u2580", egc));
CHECK(0xffffff == channels_fg_rgb(channels));
CHECK(0xffffff == channels_bg_rgb(channels));
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,
};
Expand All @@ -116,6 +154,11 @@ TEST_CASE("Stacking") {
.leny = 2, .lenx = 2, .blitter = NCBLIT_2x2, .flags = 0,
};
CHECK(top == ncvisual_render(nc_, ncv, &vopts));
/*
cell c = CELL_TRIVIAL_INITIALIZER;
ncplane_at_yx_cell(top, 0, 0, &c);
fprintf(stderr, "[[[%s]]] %016lx\n", cell_extended_gcluster(top, &c), c.channels);
*/
ncvisual_destroy(ncv);

// create an ncvisual of 2 rows, 2 columns, with the tr, bl 0xffffff
Expand Down

0 comments on commit 19a650e

Please sign in to comment.