wide tests: ncplane_new -> ncplane_create #1115

This commit is contained in:
nick black 2020-11-14 17:00:07 -05:00 committed by Nick Black
parent da5c1b2ed4
commit ff999ca268
2 changed files with 88 additions and 8 deletions

View File

@ -290,7 +290,17 @@ TEST_CASE("Reels") {
notcurses_term_dim_yx(nc_, &dimy, &dimx);
uint64_t channels = 0;
channels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT);
auto ncp = ncplane_new(n_, dimy, dimx, 0, 0, nullptr, nullptr);
struct ncplane_options nopts = {
.y = 0,
.horiz = { .x = 0, },
.rows = dimy,
.cols = dimx,
.userptr = nullptr,
.name = nullptr,
.resizecb = nullptr,
.flags = 0,
};
auto ncp = ncplane_create(n_, &nopts);
REQUIRE(nullptr != ncp);
CHECK(0 == ncplane_set_base(ncp, "", 0, channels));
struct ncreel* nr = ncreel_create(n_, &r);

View File

@ -222,7 +222,17 @@ TEST_CASE("Wide") {
}
SUBCASE("BoxedWideGlyph") {
struct ncplane* ncp = ncplane_new(n_, 3, 4, 0, 0, nullptr, nullptr);
struct ncplane_options nopts = {
.y = 0,
.horiz = { .x = 0, },
.rows = 3,
.cols = 4,
.userptr = nullptr,
.name = nullptr,
.resizecb = nullptr,
.flags = 0,
};
struct ncplane* ncp = ncplane_create(n_, &nopts);
REQUIRE(ncp);
int dimx, dimy;
ncplane_dim_yx(n_, &dimy, &dimx);
@ -336,7 +346,17 @@ TEST_CASE("Wide") {
free(egc);
cell_init(&c);
struct ncplane* n = ncplane_new(n_, 1, 2, 0, 1, nullptr, nullptr);
struct ncplane_options nopts = {
.y = 0,
.horiz = { .x = 1, },
.rows = 1,
.cols = 2,
.userptr = nullptr,
.name = nullptr,
.resizecb = nullptr,
.flags = 0,
};
struct ncplane* n = ncplane_create(n_, &nopts);
REQUIRE(n);
CHECK(0 < ncplane_putstr(n, "AB"));
CHECK(!notcurses_render(nc_));
@ -373,7 +393,17 @@ TEST_CASE("Wide") {
// Render a translucent plane atop a wide glyph, and check the colors on both
// cells. See https://github.com/dankamongmen/notcurses/issues/362.
SUBCASE("OverWide") {
struct ncplane* p = ncplane_new(n_, 3, 4, 0, 0, nullptr, nullptr);
struct ncplane_options nopts = {
.y = 0,
.horiz = { .x = 0, },
.rows = 3,
.cols = 4,
.userptr = nullptr,
.name = nullptr,
.resizecb = nullptr,
.flags = 0,
};
struct ncplane* p = ncplane_create(n_, &nopts);
REQUIRE(nullptr != p);
cell c = CELL_CHAR_INITIALIZER('X');
CHECK(0 == ncplane_perimeter(p, &c, &c, &c, &c, &c, &c, 0));
@ -412,7 +442,17 @@ TEST_CASE("Wide") {
notcurses_cursor_disable(nc_);
CHECK(0 == ncplane_set_fg_rgb8(n_, 0xff, 0, 0xff));
// start the 1x4 top plane at 0, 4
struct ncplane* topp = ncplane_new(n_, 1, 4, 0, 4, nullptr, nullptr);
struct ncplane_options nopts = {
.y = 0,
.horiz = { .x = 4, },
.rows = 1,
.cols = 4,
.userptr = nullptr,
.name = nullptr,
.resizecb = nullptr,
.flags = 0,
};
struct ncplane* topp = ncplane_create(n_, &nopts);
REQUIRE(nullptr != topp);
CHECK(0 == ncplane_set_bg_rgb8(topp, 0, 0xff, 0));
CHECK(4 == ncplane_putstr(topp, "abcd"));
@ -586,7 +626,17 @@ TEST_CASE("Wide") {
SUBCASE("WidePlaneAtopWide") {
CHECK(0 == ncplane_set_fg_rgb8(n_, 0xff, 0, 0xff));
// start the 1x4 top plane at 0, 4
struct ncplane* topp = ncplane_new(n_, 1, 4, 0, 4, nullptr, nullptr);
struct ncplane_options nopts = {
.y = 0,
.horiz = { .x = 4, },
.rows = 1,
.cols = 4,
.userptr = nullptr,
.name = nullptr,
.resizecb = nullptr,
.flags = 0,
};
struct ncplane* topp = ncplane_create(n_, &nopts);
REQUIRE(nullptr != topp);
CHECK(0 == ncplane_set_bg_rgb8(topp, 0, 0xff, 0));
CHECK(6 == ncplane_putstr(topp, "次次"));
@ -731,7 +781,17 @@ TEST_CASE("Wide") {
SUBCASE("WidePlaneAtopNarrow") {
CHECK(0 == ncplane_set_fg_rgb8(n_, 0xff, 0, 0xff));
// start the 1x4 top plane at 0, 4
struct ncplane* topp = ncplane_new(n_, 1, 4, 0, 4, nullptr, nullptr);
struct ncplane_options nopts = {
.y = 0,
.horiz = { .x = 4, },
.rows = 1,
.cols = 4,
.userptr = nullptr,
.name = nullptr,
.resizecb = nullptr,
.flags = 0,
};
struct ncplane* topp = ncplane_create(n_, &nopts);
REQUIRE(nullptr != topp);
CHECK(0 == ncplane_set_bg_rgb8(topp, 0, 0xff, 0));
CHECK(6 == ncplane_putstr(topp, "次次"));
@ -915,7 +975,17 @@ TEST_CASE("Wide") {
// a higher glyph ought not be annihilated by a lower wide glyph
SUBCASE("HigherGlyphAbides") {
auto high = ncplane_new(n_, 1, 1, 0, 0, nullptr, nullptr);
struct ncplane_options nopts = {
.y = 0,
.horiz = { .x = 0, },
.rows = 1,
.cols = 1,
.userptr = nullptr,
.name = nullptr,
.resizecb = nullptr,
.flags = 0,
};
auto high = ncplane_create(n_, &nopts);
REQUIRE(nullptr != high);
CHECK(0 < ncplane_putchar_yx(high, 0, 0, 'a'));
CHECK(0 < ncplane_putegc_yx(n_, 0, 0, "", nullptr));