From e57999d226aedb4b71ac379b8d6b187da047743c Mon Sep 17 00:00:00 2001 From: nick black Date: Tue, 7 Dec 2021 19:09:35 -0500 Subject: [PATCH] basic autogrow tests #2440 --- src/tests/autogrow.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/tests/autogrow.cpp b/src/tests/autogrow.cpp index c4f6287b6..cb14683cf 100644 --- a/src/tests/autogrow.cpp +++ b/src/tests/autogrow.cpp @@ -15,6 +15,37 @@ TEST_CASE("Autogrow") { CHECK(!ncplane_set_autogrow(n_, false)); // attempt to enable failed? } + // by default, a new plane ought not have autogrow enabled--but we ought be + // able to enable(+disable) it, unlike the standard plane. + SUBCASE("AutogrowDisabledNewPlane") { + struct ncplane_options nopts{}; + nopts.rows = 10; + nopts.cols = 10; + auto np = ncplane_create(n_, &nopts); + REQUIRE(np); + CHECK(!ncplane_set_autogrow(np, true)); // ought be false by default + CHECK(ncplane_set_autogrow(np, false)); // did we set it true? + CHECK(!ncplane_set_autogrow(np, false)); // did we set it false? + CHECK(0 == notcurses_render(nc_)); + CHECK(0 == ncplane_destroy(np)); + } + + // with the NCPLANE_OPTION_AUTOGROW flag, the plane ought have autogrow + // enabled upon creation. we ought be able to disable it. + SUBCASE("AutogrowDisabledNewPlane") { + struct ncplane_options nopts{}; + nopts.rows = 10; + nopts.cols = 10; + nopts.flags = NCPLANE_OPTION_AUTOGROW; + auto np = ncplane_create(n_, &nopts); + REQUIRE(np); + CHECK(ncplane_set_autogrow(np, false)); // ought be true at creation + CHECK(!ncplane_set_autogrow(np, true)); // did we set it false? + CHECK(ncplane_set_autogrow(np, false)); // did we set it true? + CHECK(0 == notcurses_render(nc_)); + CHECK(0 == ncplane_destroy(np)); + } + CHECK(0 == notcurses_stop(nc_)); }