diff --git a/src/tests/multiselector.cpp b/src/tests/multiselector.cpp new file mode 100644 index 000000000..e76addc3e --- /dev/null +++ b/src/tests/multiselector.cpp @@ -0,0 +1,52 @@ +#include "main.h" +#include +#include + +TEST_CASE("Multiselectors") { + auto nc_ = testing_notcurses(); + if(!nc_){ + return; + } + struct ncplane* n_ = notcurses_stdplane(nc_); + REQUIRE(n_); + REQUIRE(0 == ncplane_cursor_move_yx(n_, 0, 0)); + + // multiselector can't be bound to the standard plane + SUBCASE("RefuseStandardPlane") { + ncmultiselector_options s{}; + struct ncmultiselector* ns = ncmultiselector_create(n_, &s); + REQUIRE(nullptr == ns); + } + + // create a multiselector, but don't explicitly destroy it, thus testing the + // context shutdown cleanup path + SUBCASE("ImplicitDestroy") { + ncmultiselector_options s{}; + struct ncplane_options nopts{}; + nopts.rows = 1; + nopts.cols = 1; + struct ncplane* n = ncplane_create(n_, &nopts); + REQUIRE(nullptr != n); + struct ncmultiselector* ns = ncmultiselector_create(n, &s); + REQUIRE(ns); + CHECK(0 == notcurses_render(nc_)); + } + + // now do the same, but with a plane we have created. + SUBCASE("RefuseBoundCreatedPlane") { + struct ncplane_options nopts{}; + nopts.rows = ncplane_dim_y(n_); + nopts.cols = ncplane_dim_x(n_); + auto ncp = ncplane_create(n_, &nopts); + REQUIRE(nullptr != ncp); + ncmultiselector_options s{}; + struct ncmultiselector* ns = ncmultiselector_create(ncp, &s); + REQUIRE(ns); + CHECK(0 == notcurses_render(nc_)); + struct ncmultiselector* fail = ncmultiselector_create(ncp, &s); + CHECK(nullptr == fail); + CHECK(0 == notcurses_render(nc_)); + } + + CHECK(0 == notcurses_stop(nc_)); +} diff --git a/src/tests/reader.cpp b/src/tests/reader.cpp index fd83873e0..fdd6b53da 100644 --- a/src/tests/reader.cpp +++ b/src/tests/reader.cpp @@ -27,8 +27,7 @@ TEST_CASE("Readers") { }; auto ncp = ncplane_create(notcurses_stdplane(nc_), &nopts); uint64_t echannels = NCCHANNELS_INITIALIZER(0xff, 0x44, 0xff, 0, 0, 0); - ncplane_set_base(ncp, notcurses_canutf8(nc_) ? strdup("▒") : strdup("x"), - 0, echannels); + ncplane_set_base(ncp, notcurses_canutf8(nc_) ? "\u2592" : "x", 0, echannels); auto nr = ncreader_create(ncp, &opts); REQUIRE(nullptr != nr); CHECK(0 == notcurses_render(nc_)); diff --git a/src/tests/stacking.cpp b/src/tests/stacking.cpp index 7f8bc73fa..35cbb6b59 100644 --- a/src/tests/stacking.cpp +++ b/src/tests/stacking.cpp @@ -66,6 +66,7 @@ TEST_CASE("Stacking") { // ought yield space with white background FIXME currently just yields // a lower half block CHECK(0 == strcmp("\u2584", egc)); + free(egc); CHECK(0xffffff == ncchannels_fg_rgb(channels)); CHECK(0xffffff == ncchannels_bg_rgb(channels)); CHECK(0 == ncplane_destroy(top)); @@ -151,6 +152,7 @@ TEST_CASE("Stacking") { // ought yield space with white background FIXME currently just yields // an upper half block CHECK(0 == strcmp("\u2580", egc)); + free(egc); CHECK(0x00ff00 == ncchannels_fg_rgb(channels)); CHECK(0x00ff00 == ncchannels_bg_rgb(channels)); CHECK(0 == ncplane_destroy(top));