diff --git a/src/tests/main.cpp b/src/tests/main.cpp index a32ee8de8..c690942bc 100644 --- a/src/tests/main.cpp +++ b/src/tests/main.cpp @@ -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; } diff --git a/src/tests/textlayout.cpp b/src/tests/textlayout.cpp index 506fd3f5e..79ddcca75 100644 --- a/src/tests/textlayout.cpp +++ b/src/tests/textlayout.cpp @@ -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_)); }