From ff999ca268df077b0e04c2a8f2f9d7a3c104147d Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 14 Nov 2020 17:00:07 -0500 Subject: [PATCH] wide tests: ncplane_new -> ncplane_create #1115 --- tests/reel.cpp | 12 +++++++- tests/wide.cpp | 84 +++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 88 insertions(+), 8 deletions(-) diff --git a/tests/reel.cpp b/tests/reel.cpp index 7024cf613..0f2ce6b8c 100644 --- a/tests/reel.cpp +++ b/tests/reel.cpp @@ -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); diff --git a/tests/wide.cpp b/tests/wide.cpp index 33e3e7a2a..5f27c64a0 100644 --- a/tests/wide.cpp +++ b/tests/wide.cpp @@ -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));