unit tests for ncplane_moverel()

This commit is contained in:
nick black 2021-07-04 13:50:19 -04:00
parent cd80b70594
commit 0941efbea5
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -1001,6 +1001,45 @@ TEST_CASE("Plane") {
}while(c != 127);
}
// relative moves
SUBCASE("RelativePlaneMoves") {
struct ncplane_options nopts{};
nopts.x = 2;
nopts .y = 2;
nopts.rows = 4;
nopts.cols = 4;
auto n = ncplane_create(n_, &nopts);
REQUIRE(nullptr != n);
uint64_t channels = CHANNELS_RGB_INITIALIZER(0, 0xff, 0, 0xff, 0, 0xff);
int y, x;
ncplane_yx(n, &y, &x);
CHECK(y == 2);
CHECK(x == 2);
CHECK(1 == ncplane_set_base(n, " ", 0, channels));
CHECK(0 == notcurses_render(nc_));
CHECK(0 == ncplane_moverel(n, -1, 0)); // up
ncplane_yx(n, &y, &x);
CHECK(y == 1);
CHECK(x == 2);
CHECK(0 == notcurses_render(nc_));
CHECK(0 == ncplane_moverel(n, 2, 0)); // down
ncplane_yx(n, &y, &x);
CHECK(y == 3);
CHECK(x == 2);
CHECK(0 == notcurses_render(nc_));
CHECK(0 == ncplane_moverel(n, 0, -1)); // left
ncplane_yx(n, &y, &x);
CHECK(y == 3);
CHECK(x == 1);
CHECK(0 == notcurses_render(nc_));
CHECK(0 == ncplane_moverel(n, 0, 2)); // right
ncplane_yx(n, &y, &x);
CHECK(y == 3);
CHECK(x == 3);
CHECK(0 == notcurses_render(nc_));
CHECK(0 == ncplane_destroy(n));
}
CHECK(0 == notcurses_stop(nc_));
}