2020-05-07 19:06:07 +00:00
|
|
|
#include "main.h"
|
|
|
|
#include <cstring>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
TEST_CASE("Readers") {
|
2020-06-16 03:58:43 +00:00
|
|
|
auto nc_ = testing_notcurses();
|
2020-05-17 11:57:21 +00:00
|
|
|
if(!nc_){
|
|
|
|
return;
|
|
|
|
}
|
2020-05-07 19:06:07 +00: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 17:30:29 +00:00
|
|
|
SUBCASE("ReaderRender") {
|
2020-05-07 19:33:36 +00:00
|
|
|
ncreader_options opts{};
|
2020-09-18 08:01:19 +00:00
|
|
|
auto ncp = ncplane_new(notcurses_stdplane(nc_), dimy / 2, dimx / 2, 0, 0, nullptr, nullptr);
|
2020-09-13 17:53:11 +00:00
|
|
|
uint64_t echannels = CHANNELS_RGB_INITIALIZER(0xff, 0x44, 0xff, 0, 0, 0);
|
|
|
|
ncplane_set_base(ncp, enforce_utf8() ? strdup("▒") : strdup("x"), 0, echannels);
|
|
|
|
auto nr = ncreader_create(ncp, &opts);
|
2020-05-07 19:06:07 +00:00
|
|
|
REQUIRE(nullptr != nr);
|
2020-05-08 17:30:29 +00:00
|
|
|
CHECK(0 == notcurses_render(nc_));
|
2020-05-09 01:30:45 +00:00
|
|
|
char* contents = nullptr;
|
2020-05-08 20:16:24 +00:00
|
|
|
ncreader_destroy(nr, &contents);
|
|
|
|
REQUIRE(contents);
|
2020-05-07 19:06:07 +00:00
|
|
|
CHECK(0 == notcurses_render(nc_));
|
|
|
|
}
|
|
|
|
|
|
|
|
CHECK(0 == notcurses_stop(nc_));
|
|
|
|
}
|