2020-05-07 15:06:07 -04:00
|
|
|
#include "main.h"
|
|
|
|
#include <cstring>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
TEST_CASE("Readers") {
|
2020-06-15 23:58:43 -04:00
|
|
|
auto nc_ = testing_notcurses();
|
2020-05-17 07:57:21 -04:00
|
|
|
if(!nc_){
|
|
|
|
return;
|
|
|
|
}
|
2020-05-07 15:06:07 -04:00
|
|
|
int dimx, dimy;
|
|
|
|
struct ncplane* n_ = notcurses_stddim_yx(nc_, &dimy, &dimx);
|
|
|
|
REQUIRE(n_);
|
|
|
|
REQUIRE(0 == ncplane_cursor_move_yx(n_, 0, 0));
|
|
|
|
|
2020-05-08 13:30:29 -04:00
|
|
|
SUBCASE("ReaderRender") {
|
2020-05-07 15:33:36 -04:00
|
|
|
ncreader_options opts{};
|
2020-11-14 16:48:34 -05:00
|
|
|
struct ncplane_options nopts = {
|
|
|
|
.y = 0,
|
2020-11-14 21:42:37 -05:00
|
|
|
.x = 0,
|
2020-11-14 16:48:34 -05:00
|
|
|
.rows = dimy / 2,
|
|
|
|
.cols = dimx / 2,
|
|
|
|
.userptr = nullptr,
|
|
|
|
.name = nullptr,
|
|
|
|
.resizecb = nullptr,
|
|
|
|
.flags = 0,
|
|
|
|
};
|
|
|
|
auto ncp = ncplane_create(notcurses_stdplane(nc_), &nopts);
|
2020-09-13 13:53:11 -04:00
|
|
|
uint64_t echannels = CHANNELS_RGB_INITIALIZER(0xff, 0x44, 0xff, 0, 0, 0);
|
2020-11-28 23:15:07 -05:00
|
|
|
ncplane_set_base(ncp, notcurses_canutf8(nc_) ? strdup("▒") : strdup("x"),
|
|
|
|
0, echannels);
|
2020-09-13 13:53:11 -04:00
|
|
|
auto nr = ncreader_create(ncp, &opts);
|
2020-05-07 15:06:07 -04:00
|
|
|
REQUIRE(nullptr != nr);
|
2020-05-08 13:30:29 -04:00
|
|
|
CHECK(0 == notcurses_render(nc_));
|
2020-05-08 21:30:45 -04:00
|
|
|
char* contents = nullptr;
|
2020-05-08 16:16:24 -04:00
|
|
|
ncreader_destroy(nr, &contents);
|
|
|
|
REQUIRE(contents);
|
2020-05-07 15:06:07 -04:00
|
|
|
CHECK(0 == notcurses_render(nc_));
|
|
|
|
}
|
|
|
|
|
|
|
|
CHECK(0 == notcurses_stop(nc_));
|
|
|
|
}
|