Ncpp tests: supply NCOPTION_SUPPRESS_BANNERS | NCOPTION_INHIBIT_SETLOCALE

pull/821/head
nick black 4 years ago committed by Nick Black
parent 2ecfb84fe8
commit bae1cedd6b

@ -6,17 +6,21 @@ using namespace ncpp;
TEST_CASE("Ncpp" TEST_CASE("Ncpp"
* doctest::description("Basic C++ wrapper tests")) { * doctest::description("Basic C++ wrapper tests")) {
notcurses_options nopts{};
nopts.flags = NCOPTION_SUPPRESS_BANNERS |
NCOPTION_INHIBIT_SETLOCALE;
// we ought be able to construct a NotCurses object with a nullptr FILE // we ought be able to construct a NotCurses object with a nullptr FILE
// or even just no argument (decays to nullptr). // or even just no argument (decays to nullptr).
SUBCASE("ConstructNotCurses") { SUBCASE("ConstructNotCurses") {
NotCurses nc; NotCurses nc{ nopts };
CHECK(!NotCurses::is_notcurses_stopped(&nc)); CHECK(!NotCurses::is_notcurses_stopped(&nc));
CHECK(nc.stop()); CHECK(nc.stop());
CHECK(NotCurses::is_notcurses_stopped(&nc)); CHECK(NotCurses::is_notcurses_stopped(&nc));
} }
SUBCASE("ConstructNotCursesNullFILE") { SUBCASE("ConstructNotCursesNullFILE") {
NotCurses ncnull(nullptr); NotCurses ncnull{ nopts, nullptr };
CHECK(!NotCurses::is_notcurses_stopped(&ncnull)); CHECK(!NotCurses::is_notcurses_stopped(&ncnull));
CHECK(ncnull.stop()); CHECK(ncnull.stop());
CHECK(NotCurses::is_notcurses_stopped(&ncnull)); CHECK(NotCurses::is_notcurses_stopped(&ncnull));
@ -24,17 +28,17 @@ TEST_CASE("Ncpp"
// we ought be able to get a new NotCurses object after stop()ping one. // we ought be able to get a new NotCurses object after stop()ping one.
SUBCASE("ConstructNotCursesTwice") { SUBCASE("ConstructNotCursesTwice") {
NotCurses nc; NotCurses nc{ nopts };
CHECK(nc.stop()); CHECK(nc.stop());
CHECK(NotCurses::is_notcurses_stopped(&nc)); CHECK(NotCurses::is_notcurses_stopped(&nc));
NotCurses ncnull(nullptr); NotCurses ncnull{ nopts, nullptr };
CHECK(!NotCurses::is_notcurses_stopped(&ncnull)); CHECK(!NotCurses::is_notcurses_stopped(&ncnull));
CHECK(ncnull.stop()); CHECK(ncnull.stop());
CHECK(NotCurses::is_notcurses_stopped(&ncnull)); CHECK(NotCurses::is_notcurses_stopped(&ncnull));
} }
SUBCASE("StdPlane") { SUBCASE("StdPlane") {
NotCurses nc; NotCurses nc{ nopts };
auto std1 = nc.get_stdplane(); auto std1 = nc.get_stdplane();
CHECK(nullptr != std1); CHECK(nullptr != std1);
int y, x; int y, x;
@ -46,19 +50,19 @@ TEST_CASE("Ncpp"
} }
SUBCASE("Debug") { // just test to ensure it doesn't coredump SUBCASE("Debug") { // just test to ensure it doesn't coredump
NotCurses nc; NotCurses nc{ nopts };
nc.debug(stderr); nc.debug(stderr);
CHECK(nc.stop()); CHECK(nc.stop());
} }
SUBCASE("GetPaletteSize") { SUBCASE("GetPaletteSize") {
NotCurses nc; NotCurses nc{ nopts };
CHECK(0 < nc.get_palette_size()); CHECK(0 < nc.get_palette_size());
CHECK(nc.stop()); CHECK(nc.stop());
} }
SUBCASE("VisualFromFile") { SUBCASE("VisualFromFile") {
NotCurses nc; NotCurses nc{ nopts };
if(nc.can_open_images()){ if(nc.can_open_images()){
nc_err_e err; nc_err_e err;
{ {
@ -70,7 +74,7 @@ TEST_CASE("Ncpp"
} }
SUBCASE("VisualFromRGBA") { SUBCASE("VisualFromRGBA") {
NotCurses nc; NotCurses nc{ nopts };
uint32_t rgba[] = { uint32_t rgba[] = {
0x4080c0ff, 0x4080c0ff,
0x105090ff, 0x105090ff,
@ -83,7 +87,7 @@ TEST_CASE("Ncpp"
} }
SUBCASE("VisualFromPlane") { SUBCASE("VisualFromPlane") {
NotCurses nc; NotCurses nc{ nopts };
{ {
auto n = nc.get_stdplane(); auto n = nc.get_stdplane();
REQUIRE(n); REQUIRE(n);

@ -203,16 +203,16 @@ fprintf(stderr, "LINE: [%s]\n", line);
// create a plane of two rows, and exactly fill both with wide chars // create a plane of two rows, and exactly fill both with wide chars
SUBCASE("LayoutFillsPlaneWide") { SUBCASE("LayoutFillsPlaneWide") {
auto sp = ncplane_new(nc_, 2, 8, 0, 0, nullptr); auto sp = ncplane_new(nc_, 2, 7, 0, 0, nullptr);
REQUIRE(sp); REQUIRE(sp);
size_t bytes; size_t bytes;
const char boundstr[] = "我能吞 下玻 "; const char boundstr[] = "我能吞 下玻";
CHECK(0 < ncplane_puttext(sp, 0, NCALIGN_LEFT, boundstr, &bytes)); CHECK(0 < ncplane_puttext(sp, 0, NCALIGN_LEFT, boundstr, &bytes));
CHECK(0 == notcurses_render(nc_)); CHECK(0 == notcurses_render(nc_));
CHECK(bytes == strlen(boundstr)); CHECK(bytes == strlen(boundstr));
char* line = ncplane_contents(sp, 0, 0, -1, -1); char* line = ncplane_contents(sp, 0, 0, -1, -1);
REQUIRE(line); REQUIRE(line);
CHECK(0 == strcmp(line, "我能吞下玻 ")); CHECK(0 == strcmp(line, "我能吞下玻"));
free(line); free(line);
ncplane_destroy(sp); ncplane_destroy(sp);
} }

@ -17,7 +17,6 @@ auto testing_notcurses() -> struct notcurses* {
notcurses_options nopts{}; notcurses_options nopts{};
nopts.loglevel = NCLOGLEVEL_VERBOSE; nopts.loglevel = NCLOGLEVEL_VERBOSE;
nopts.flags = NCOPTION_SUPPRESS_BANNERS nopts.flags = NCOPTION_SUPPRESS_BANNERS
| NCOPTION_NO_ALTERNATE_SCREEN
| NCOPTION_INHIBIT_SETLOCALE; | NCOPTION_INHIBIT_SETLOCALE;
auto nc = notcurses_init(&nopts, nullptr); auto nc = notcurses_init(&nopts, nullptr);
return nc; return nc;

Loading…
Cancel
Save