[tester] kill memory leaks in two unit tests

dankamongmen/windows-tester
nick black 3 years ago
parent ce2a6dc686
commit 01c6f8ba3d
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -0,0 +1,52 @@
#include "main.h"
#include <cstring>
#include <iostream>
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_));
}

@ -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_));

@ -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));

Loading…
Cancel
Save