mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
another scrolling unit test
This commit is contained in:
parent
6138ff2832
commit
a7f17040ce
@ -40,6 +40,7 @@ TEST_CASE("Fade") {
|
||||
c.gcluster = '*';
|
||||
cell_set_fg_rgb(&c, 0xff, 0xff, 0xff);
|
||||
unsigned rgb = 0xffffffu;
|
||||
CHECK(!ncplane_set_scrolling(n_, true));
|
||||
for(int y = 0 ; y < dimy ; ++y){
|
||||
for(int x = 0 ; x < dimx ; ++x){
|
||||
rgb -= 32;
|
||||
|
@ -211,6 +211,7 @@ TEST_CASE("NCPlane") {
|
||||
L"🍺🚬🌿💉💊🔫💣🤜🤛🐌🐎🐑🐒🐔🐗🐘🐙🐚"
|
||||
"🐛🐜🐝🐞🐟🐠🐡🐢🐣🐤🐥🐦🐧🐨🐩🐫🐬🐭🐮"
|
||||
"🐯🐰🐱🐲🐳🐴🐵🐶🐷🐹🐺🐻🐼🦉🐊🦕🦖🐬🐙🦠🦀";
|
||||
CHECK(!ncplane_set_scrolling(n_, true));
|
||||
int wrote = ncplane_putwstr(n_, e);
|
||||
CHECK(0 < wrote);
|
||||
int x, y;
|
||||
@ -539,20 +540,20 @@ TEST_CASE("NCPlane") {
|
||||
ncplane_styles_set(n_, 0);
|
||||
REQUIRE(0 == ncplane_cursor_move_yx(n_, 0, 0));
|
||||
REQUIRE(0 < ncplane_putstr(n_, STR1));
|
||||
cell testcell = CELL_TRIVIAL_INITIALIZER;
|
||||
REQUIRE(0 == ncplane_at_cursor(n_, &testcell)); // want nothing at the cursor
|
||||
CHECK(0 == testcell.gcluster);
|
||||
CHECK(0 == testcell.attrword);
|
||||
CHECK(0 == testcell.channels);
|
||||
int dimy, dimx;
|
||||
ncplane_dim_yx(n_, &dimy, &dimx);
|
||||
REQUIRE(0 == ncplane_cursor_move_yx(n_, 1, dimx - strlen(STR2)));
|
||||
REQUIRE(0 < ncplane_putstr(n_, STR2));
|
||||
int y, x;
|
||||
ncplane_cursor_yx(n_, &y, &x);
|
||||
REQUIRE(2 == y);
|
||||
REQUIRE(0 == x);
|
||||
REQUIRE(0 < ncplane_putstr(n_, STR3));
|
||||
cell testcell = CELL_TRIVIAL_INITIALIZER;
|
||||
REQUIRE(0 == ncplane_at_cursor(n_, &testcell)); // want nothing at the cursor
|
||||
CHECK(0 == testcell.gcluster);
|
||||
CHECK(0 == testcell.attrword);
|
||||
CHECK(0 == testcell.channels);
|
||||
REQUIRE(1 == y);
|
||||
REQUIRE(dimx == x);
|
||||
REQUIRE(0 == ncplane_putstr(n_, STR3));
|
||||
REQUIRE(0 == ncplane_cursor_move_yx(n_, 0, 0));
|
||||
REQUIRE(0 < ncplane_at_cursor(n_, &testcell)); // want first char of STR1
|
||||
CHECK(STR1[0] == testcell.gcluster);
|
||||
@ -575,20 +576,20 @@ TEST_CASE("NCPlane") {
|
||||
ncplane_styles_set(n_, 0);
|
||||
REQUIRE(0 == ncplane_cursor_move_yx(n_, 0, 0));
|
||||
REQUIRE(0 < ncplane_putstr(n_, STR1));
|
||||
cell testcell = CELL_TRIVIAL_INITIALIZER;
|
||||
ncplane_at_cursor(n_, &testcell); // should be nothing at the cursor
|
||||
CHECK(0 == testcell.gcluster);
|
||||
CHECK(0 == testcell.attrword);
|
||||
CHECK(0 == testcell.channels);
|
||||
int dimy, dimx;
|
||||
ncplane_dim_yx(n_, &dimy, &dimx);
|
||||
REQUIRE(0 == ncplane_cursor_move_yx(n_, 1, dimx - mbstowcs(NULL, STR2, 0)));
|
||||
REQUIRE(0 < ncplane_putstr(n_, STR2));
|
||||
int y, x;
|
||||
ncplane_cursor_yx(n_, &y, &x);
|
||||
REQUIRE(2 == y);
|
||||
REQUIRE(0 == x);
|
||||
REQUIRE(0 < ncplane_putstr(n_, STR3));
|
||||
cell testcell = CELL_TRIVIAL_INITIALIZER;
|
||||
ncplane_at_cursor(n_, &testcell); // should be nothing at the cursor
|
||||
CHECK(0 == testcell.gcluster);
|
||||
CHECK(0 == testcell.attrword);
|
||||
CHECK(0 == testcell.channels);
|
||||
REQUIRE(1 == y);
|
||||
REQUIRE(dimx == x);
|
||||
REQUIRE(0 == ncplane_putstr(n_, STR3));
|
||||
REQUIRE(0 == ncplane_cursor_move_yx(n_, 0, 0));
|
||||
REQUIRE(0 < ncplane_at_cursor(n_, &testcell)); // want first char of STR1
|
||||
CHECK(!strcmp("Σ", cell_extended_gcluster(n_, &testcell)));
|
||||
@ -916,7 +917,7 @@ TEST_CASE("NCPlane") {
|
||||
int dimx, dimy;
|
||||
ncplane_dim_yx(n_, &dimy, &dimx);
|
||||
CHECK(0 == ncplane_rounded_box_sized(ncp, 0, 0, 3, 4, 0));
|
||||
CHECK(0 < ncplane_putegc_yx(ncp, 1, 1, "\xf0\x9f\xa6\x82", NULL));
|
||||
CHECK(2 == ncplane_putegc_yx(ncp, 1, 1, "\xf0\x9f\xa6\x82", NULL)); // scorpion
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
cell c = CELL_TRIVIAL_INITIALIZER;
|
||||
REQUIRE(0 < ncplane_at_yx(ncp, 1, 0, &c));
|
||||
|
@ -30,18 +30,37 @@ TEST_CASE("Scrolling") {
|
||||
// verify that the new plane was started without scrolling
|
||||
CHECK(!ncplane_set_scrolling(n, false));
|
||||
// try to write 40 EGCs; it ought fail
|
||||
CHECK(0 > ncplane_putstr(n, "01234567890123456789012345678901234567689"));
|
||||
CHECK(-20 == ncplane_putstr(n, "0123456789012345678901234567890123456789"));
|
||||
int y, x;
|
||||
ncplane_cursor_yx(n, &y, &x);
|
||||
CHECK(0 == y);
|
||||
CHECK(20 == x);
|
||||
CHECK(0 == ncplane_cursor_move_yx(n, 0, 0));
|
||||
CHECK(!ncplane_set_scrolling(n, true)); // enable scrolling
|
||||
// try to write 40 EGCs; it ought succeed
|
||||
CHECK(40 == ncplane_putstr(n, "01234567890123456789012345678901234567689"));
|
||||
int y, x;
|
||||
CHECK(40 == ncplane_putstr(n, "0123456789012345678901234567890123456789"));
|
||||
ncplane_cursor_yx(n, &y, &x);
|
||||
CHECK(1 == y);
|
||||
CHECK(20 == x);
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
}
|
||||
|
||||
// even when scrolling is enabled, you aren't allowed to move the cursor
|
||||
// off-plane, or initiate output there
|
||||
SUBCASE("NoScrollingManually"){
|
||||
struct ncplane* n = ncplane_new(nc_, 2, 20, 1, 1, nullptr);
|
||||
REQUIRE(n);
|
||||
CHECK(!ncplane_set_scrolling(n, true)); // enable scrolling
|
||||
CHECK(0 > ncplane_cursor_move_yx(n, 0, 20));
|
||||
CHECK(0 > ncplane_cursor_move_yx(n, 1, 20));
|
||||
CHECK(0 > ncplane_cursor_move_yx(n, 2, 2));
|
||||
CHECK(0 > ncplane_putsimple_yx(n, 0, 20, 'c'));
|
||||
CHECK(0 > ncplane_putsimple_yx(n, 1, 20, 'c'));
|
||||
CHECK(0 > ncplane_putsimple_yx(n, 2, 0, 'c'));
|
||||
}
|
||||
|
||||
// verify that two strings, each the length of the plane, can be output when
|
||||
// scrolling is enabled (the second ought get an error without scrolling)
|
||||
SUBCASE("ScrollingSplitStr"){
|
||||
struct ncplane* n = ncplane_new(nc_, 2, 20, 1, 1, nullptr);
|
||||
REQUIRE(n);
|
||||
@ -50,17 +69,19 @@ TEST_CASE("Scrolling") {
|
||||
ncplane_cursor_yx(n, &y, &x);
|
||||
CHECK(0 == y);
|
||||
CHECK(20 == x);
|
||||
CHECK(0 > ncplane_putstr(n, "01234567890123456789"));
|
||||
CHECK(0 == ncplane_putstr(n, "01234567890123456789"));
|
||||
CHECK(!ncplane_set_scrolling(n, true)); // enable scrolling
|
||||
CHECK(20 > ncplane_putstr(n, "01234567890123456789"));
|
||||
CHECK(20 == ncplane_putstr(n, "01234567890123456789"));
|
||||
ncplane_cursor_yx(n, &y, &x);
|
||||
CHECK(1 == y);
|
||||
CHECK(20 == x);
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
}
|
||||
|
||||
// verify that a single string the size of the plane can be output when
|
||||
// scrolling is enabled (it ought be an error without scrolling)
|
||||
SUBCASE("ScrollingEGC"){
|
||||
const char* out = "01234567890123456789012345678901234567689";
|
||||
const char* out = "0123456789012345678901234567890123456789";
|
||||
struct ncplane* n = ncplane_new(nc_, 2, 20, 1, 1, nullptr);
|
||||
REQUIRE(n);
|
||||
// verify that the new plane was started without scrolling
|
||||
|
Loading…
x
Reference in New Issue
Block a user