mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-08 01:10:23 +00:00
[ncplane_puttext] unit test for newline while growing plane #2446
This commit is contained in:
parent
ba1fbbee90
commit
adcdef6288
@ -18,7 +18,9 @@ auto testing_notcurses() -> struct notcurses* {
|
||||
// get loglevel from command line. enabling it by default leads to
|
||||
// more confusion than useful information, so leave it off by default.
|
||||
nopts.loglevel = cliloglevel;
|
||||
nopts.flags = NCOPTION_SUPPRESS_BANNERS | NCOPTION_NO_ALTERNATE_SCREEN;
|
||||
nopts.flags = NCOPTION_SUPPRESS_BANNERS
|
||||
| NCOPTION_NO_ALTERNATE_SCREEN
|
||||
| NCOPTION_DRAIN_INPUT;
|
||||
auto nc = notcurses_init(&nopts, nullptr);
|
||||
return nc;
|
||||
}
|
||||
|
@ -653,6 +653,44 @@ TEST_CASE("TextLayout") {
|
||||
CHECK(0 == ncplane_destroy(sp));
|
||||
}
|
||||
|
||||
// test that multiple new lines are treated as such, both on the plane
|
||||
// originally, and in any autogrown region.
|
||||
SUBCASE("MultipleNewlines") {
|
||||
struct ncplane_options nopts{};
|
||||
nopts.rows = 3;
|
||||
nopts.cols = 10;
|
||||
nopts.flags = NCPLANE_OPTION_VSCROLL | NCPLANE_OPTION_AUTOGROW;
|
||||
auto nn = ncplane_create(n_, &nopts);
|
||||
REQUIRE(nn);
|
||||
size_t b;
|
||||
CHECK(0 == ncplane_puttext(nn, -1, NCALIGN_LEFT, "\n\n", &b));
|
||||
unsigned y, x;
|
||||
ncplane_cursor_yx(nn, &y, &x);
|
||||
CHECK(2 == y);
|
||||
CHECK(0 == x);
|
||||
CHECK(3 == ncplane_puttext(nn, -1, NCALIGN_LEFT, "erp", &b));
|
||||
ncplane_cursor_yx(nn, &y, &x);
|
||||
CHECK(2 == y);
|
||||
CHECK(3 == x);
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
CHECK(0 == ncplane_puttext(nn, -1, NCALIGN_LEFT, "\n", &b));
|
||||
ncplane_cursor_yx(nn, &y, &x);
|
||||
CHECK(3 == y);
|
||||
CHECK(0 == x);
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
CHECK(0 == ncplane_puttext(nn, -1, NCALIGN_LEFT, "\n\n", &b));
|
||||
ncplane_cursor_yx(nn, &y, &x);
|
||||
CHECK(5 == y);
|
||||
CHECK(0 == x);
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
CHECK(3 == ncplane_puttext(nn, -1, NCALIGN_LEFT, "erp\n", &b));
|
||||
ncplane_cursor_yx(nn, &y, &x);
|
||||
CHECK(6 == y);
|
||||
CHECK(0 == x);
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
CHECK(0 == ncplane_destroy(nn));
|
||||
}
|
||||
|
||||
CHECK(0 == notcurses_stop(nc_));
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user