mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-16 00:13:00 +00:00
50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#include "main.h"
|
|
#include <cstring>
|
|
#include <iostream>
|
|
|
|
TEST_CASE("Readers") {
|
|
auto nc_ = testing_notcurses();
|
|
if(!nc_){
|
|
return;
|
|
}
|
|
int dimx, dimy;
|
|
struct ncplane* n_ = notcurses_stddim_yx(nc_, &dimy, &dimx);
|
|
REQUIRE(n_);
|
|
REQUIRE(0 == ncplane_cursor_move_yx(n_, 0, 0));
|
|
|
|
SUBCASE("ReaderBadOptions") {
|
|
ncreader_options opts{};
|
|
auto nr = ncreader_create(n_, 0, 0, &opts);
|
|
CHECK(!nr);
|
|
opts.physrows = 1;
|
|
nr = ncreader_create(n_, 0, 0, &opts);
|
|
CHECK(!nr);
|
|
opts.physcols = 1;
|
|
opts.physrows = 0;
|
|
nr = ncreader_create(n_, 0, 0, &opts);
|
|
CHECK(!nr);
|
|
}
|
|
|
|
SUBCASE("ReaderRender") {
|
|
ncreader_options opts{};
|
|
opts.physrows = dimy / 2;
|
|
opts.physcols = dimx / 2;
|
|
if(enforce_utf8()){
|
|
opts.egc = strdup("▒");
|
|
}else{
|
|
opts.egc = strdup("x");
|
|
}
|
|
auto nr = ncreader_create(n_, 0, 0, &opts);
|
|
REQUIRE(nullptr != nr);
|
|
channels_set_fg(&opts.echannels, 0xff44ff);
|
|
ncplane_set_base(n_, opts.egc, opts.eattrword, opts.echannels);
|
|
CHECK(0 == notcurses_render(nc_));
|
|
char* contents = nullptr;
|
|
ncreader_destroy(nr, &contents);
|
|
REQUIRE(contents);
|
|
CHECK(0 == notcurses_render(nc_));
|
|
}
|
|
|
|
CHECK(0 == notcurses_stop(nc_));
|
|
}
|