add nplane_polyfill_yx() #340
parent
ce3e5d112e
commit
124004c87c
@ -0,0 +1,59 @@
|
||||
#include <array>
|
||||
#include <cstdlib>
|
||||
#include <notcurses.h>
|
||||
#include "internal.h"
|
||||
#include "main.h"
|
||||
|
||||
TEST_CASE("Fills") {
|
||||
if(getenv("TERM") == nullptr){
|
||||
return;
|
||||
}
|
||||
notcurses_options nopts{};
|
||||
nopts.inhibit_alternate_screen = true;
|
||||
nopts.suppress_banner = true;
|
||||
FILE* outfp_ = fopen("/dev/tty", "wb");
|
||||
REQUIRE(outfp_);
|
||||
struct notcurses* nc_ = notcurses_init(&nopts, outfp_);
|
||||
REQUIRE(nc_);
|
||||
struct ncplane* n_ = notcurses_stdplane(nc_);
|
||||
REQUIRE(n_);
|
||||
|
||||
// trying to polyfill an invalid cell ought be an error
|
||||
SUBCASE("PolyfillOffplane") {
|
||||
int dimx, dimy;
|
||||
ncplane_dim_yx(n_, &dimy, &dimx);
|
||||
cell c = CELL_SIMPLE_INITIALIZER('+');
|
||||
CHECK(0 > ncplane_polyfill_yx(n_, dimy, 0, &c));
|
||||
CHECK(0 > ncplane_polyfill_yx(n_, 0, dimx, &c));
|
||||
CHECK(0 > ncplane_polyfill_yx(n_, 0, -1, &c));
|
||||
CHECK(0 > ncplane_polyfill_yx(n_, -1, 0, &c));
|
||||
}
|
||||
|
||||
SUBCASE("PolyfillEmptyPlane") {
|
||||
cell c = CELL_SIMPLE_INITIALIZER('+');
|
||||
struct ncplane* pfn = ncplane_new(nc_, 4, 4, 0, 0, nullptr);
|
||||
REQUIRE(nullptr != pfn);
|
||||
CHECK(16 == ncplane_polyfill_yx(pfn, 0, 0, &c));
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
CHECK(0 == ncplane_destroy(pfn));
|
||||
}
|
||||
|
||||
SUBCASE("PolyfillWalledPlane") {
|
||||
cell c = CELL_SIMPLE_INITIALIZER('+');
|
||||
struct ncplane* pfn = ncplane_new(nc_, 4, 4, 0, 0, nullptr);
|
||||
REQUIRE(nullptr != pfn);
|
||||
CHECK(0 < ncplane_putc_yx(pfn, 0, 1, &c));
|
||||
CHECK(0 < ncplane_putc_yx(pfn, 1, 1, &c));
|
||||
CHECK(0 < ncplane_putc_yx(pfn, 1, 0, &c));
|
||||
// Trying to fill the origin ought fill exactly one cell
|
||||
CHECK(1 == ncplane_polyfill_yx(pfn, 0, 0, &c));
|
||||
// Beyond the origin, we ought fill 12
|
||||
CHECK(12 == ncplane_polyfill_yx(pfn, 2, 2, &c));
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
CHECK(0 == ncplane_destroy(pfn));
|
||||
}
|
||||
|
||||
CHECK(0 == notcurses_stop(nc_));
|
||||
CHECK(0 == fclose(outfp_));
|
||||
|
||||
}
|
Loading…
Reference in New Issue