mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-09 19:10:48 +00:00
28431914a8
Very simple take at ncplane_puttext(), a new function for linebroken text. Also some very basic unit tests. I doubt this works very well yet, but it handles the simplest cases #682. Added nclog(), internal function for logging. #520
51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
#include "main.h"
|
|
#include "internal.h"
|
|
|
|
TEST_CASE("TextLayout") {
|
|
notcurses_options nopts{};
|
|
notcurses* nc_ = notcurses_init(&nopts, nullptr);
|
|
if(!nc_){
|
|
return;
|
|
}
|
|
ncplane* ncp_ = notcurses_stdplane(nc_);
|
|
REQUIRE(ncp_);
|
|
|
|
const char str[] = "this is going to be broken up";
|
|
|
|
SUBCASE("LayoutLeft") {
|
|
auto sp = ncplane_new(nc_, 2, 20, 0, 0, nullptr);
|
|
REQUIRE(sp);
|
|
size_t bytes;
|
|
CHECK(0 < ncplane_puttext(sp, 0, NCALIGN_LEFT, str, &bytes));
|
|
CHECK(0 == notcurses_render(nc_));
|
|
CHECK(bytes == strlen(str));
|
|
// FIXME inspect layout
|
|
ncplane_destroy(sp);
|
|
}
|
|
|
|
SUBCASE("LayoutRight") {
|
|
auto sp = ncplane_new(nc_, 2, 20, 0, 0, nullptr);
|
|
REQUIRE(sp);
|
|
size_t bytes;
|
|
CHECK(0 < ncplane_puttext(sp, 0, NCALIGN_RIGHT, str, &bytes));
|
|
CHECK(0 == notcurses_render(nc_));
|
|
CHECK(bytes == strlen(str));
|
|
// FIXME inspect layout
|
|
ncplane_destroy(sp);
|
|
}
|
|
|
|
SUBCASE("LayoutCenter") {
|
|
auto sp = ncplane_new(nc_, 2, 20, 0, 0, nullptr);
|
|
REQUIRE(sp);
|
|
size_t bytes;
|
|
CHECK(0 < ncplane_puttext(sp, 0, NCALIGN_CENTER, str, &bytes));
|
|
CHECK(0 == notcurses_render(nc_));
|
|
CHECK(bytes == strlen(str));
|
|
// FIXME inspect layout
|
|
ncplane_destroy(sp);
|
|
}
|
|
|
|
CHECK(0 == notcurses_stop(nc_));
|
|
|
|
}
|