DualCell{Left, Right} unit tests #1258

pull/1270/head
nick black 4 years ago committed by Nick Black
parent f608df2af8
commit 1c4d942cfc

@ -76,5 +76,84 @@ TEST_CASE("ProgressBar") {
}
ncprogbar_destroy(pbar);
}
SUBCASE("DualCellLeft") {
struct ncplane_options nopts = {
.y = 0,
.x = 0,
.rows = 1,
.cols = 2,
.userptr = nullptr,
.name = "pbar",
.resizecb = nullptr,
.flags = 0,
};
const char* egcs[] = { " ", "", "", "", "", "", "", "" };
auto n = ncplane_create(n_, &nopts);
REQUIRE(nullptr != n);
struct ncprogbar_options popts = {
.ulchannel = 0,
.urchannel = 0,
.blchannel = 0,
.brchannel = 0,
.flags = 0,
};
auto pbar = ncprogbar_create(n, &popts);
double p = 0;
int i = 0;
do{
CHECK(0 == ncprogbar_set_progress(pbar, p));
CHECK(0 == notcurses_render(nc_));
uint16_t smask;
uint64_t channels;
char* egc = notcurses_at_yx(nc_, 0, i / 8, &smask, &channels);
REQUIRE(nullptr != egc);
CHECK(0 == strcmp(egc, egcs[i % 8]));
free(egc);
p += 0.0625;
++i;
}while(p < 1);
ncprogbar_destroy(pbar);
}
SUBCASE("DualCellRight") {
struct ncplane_options nopts = {
.y = 0,
.x = 0,
.rows = 1,
.cols = 2,
.userptr = nullptr,
.name = "pbar",
.resizecb = nullptr,
.flags = 0,
};
const char* egcs[] = { " ", "🮇", "🮇", "🮈", "", "🮉", "🮊", "🮋" };
auto n = ncplane_create(n_, &nopts);
REQUIRE(nullptr != n);
struct ncprogbar_options popts = {
.ulchannel = 0,
.urchannel = 0,
.blchannel = 0,
.brchannel = 0,
.flags = NCPROGBAR_OPTION_RETROGRADE,
};
auto pbar = ncprogbar_create(n, &popts);
double p = 0;
int i = 0;
do{
CHECK(0 == ncprogbar_set_progress(pbar, p));
CHECK(0 == notcurses_render(nc_));
uint16_t smask;
uint64_t channels;
char* egc = notcurses_at_yx(nc_, 0, 1 - i / 8, &smask, &channels);
REQUIRE(nullptr != egc);
CHECK(0 == strcmp(egc, egcs[i % 8]));
free(egc);
p += 0.0625;
++i;
}while(p < 1);
ncprogbar_destroy(pbar);
}
CHECK(0 == notcurses_stop(nc_));
}

Loading…
Cancel
Save