From 9270a58b2db9ea70d5aa76cb8ada7aa1da351f87 Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 20 Mar 2021 03:00:29 -0400 Subject: [PATCH] [pixel] unit test on sprixel_cell_wipe() --- src/tests/pixel.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/tests/pixel.cpp b/src/tests/pixel.cpp index 56bd34c25..f51c7b50d 100644 --- a/src/tests/pixel.cpp +++ b/src/tests/pixel.cpp @@ -1,4 +1,5 @@ #include "main.h" +#include TEST_CASE("Pixel") { auto nc_ = testing_notcurses(); @@ -9,10 +10,18 @@ TEST_CASE("Pixel") { REQUIRE(n_); if(notcurses_check_pixel_support(nc_) <= 0){ + CHECK(0 == nc_->tcache.sixel_supported); CHECK(!notcurses_stop(nc_)); return; } + SUBCASE("SprixelTermValues") { + CHECK(0 < nc_->tcache.cellpixy); + CHECK(0 < nc_->tcache.cellpixx); + CHECK(nc_->tcache.sixel_supported); + CHECK(nullptr != nc_->tcache.pixel_cell_wipe); + } + #ifdef NOTCURSES_USE_MULTIMEDIA SUBCASE("PixelRender") { auto ncv = ncvisual_from_file(find_data("worldmap.png")); @@ -28,5 +37,39 @@ TEST_CASE("Pixel") { } #endif + SUBCASE("PixelCellWipe") { + // first, assemble a visual equivalent to 4 cells + auto y = nc_->tcache.cellpixy; + auto x = nc_->tcache.cellpixx; + std::vector v(x * y, 0xffffffff); + auto ncv = ncvisual_from_rgba(v.data(), y, sizeof(decltype(v)::value_type) * x, x); + REQUIRE(nullptr != ncv); + struct ncvisual_options vopts = { + .n = nullptr, + .scaling = NCSCALE_NONE, + .y = 0, .x = 0, + .begy = 0, .begx = 0, + .leny = y, .lenx = x, + .blitter = NCBLIT_PIXEL, + .flags = NCVISUAL_OPTION_NODEGRADE, + }; + auto n = ncvisual_render(nc_, ncv, &vopts); + REQUIRE(nullptr != n); + auto s = n->sprite; + REQUIRE(nullptr != s); + CHECK(0 == notcurses_render(nc_)); + CHECK(0 == nc_->tcache.pixel_cell_wipe(s, 0, 0)); + CHECK(0 == notcurses_render(nc_)); + CHECK(0 == nc_->tcache.pixel_cell_wipe(s, 1, 1)); + CHECK(0 == notcurses_render(nc_)); + CHECK(0 == nc_->tcache.pixel_cell_wipe(s, 1, 0)); + CHECK(0 == notcurses_render(nc_)); + CHECK(0 == nc_->tcache.pixel_cell_wipe(s, 0, 1)); + CHECK(0 == notcurses_render(nc_)); + ncplane_destroy(n); + ncvisual_destroy(ncv); + CHECK(0 == notcurses_render(nc_)); + } + CHECK(!notcurses_stop(nc_)); }