From adab5ba382d4e09031aed3d04be28b4d7d1b2c60 Mon Sep 17 00:00:00 2001 From: nick black Date: Mon, 17 Aug 2020 23:53:22 -0400 Subject: [PATCH] LayoutNewlines unit test #829 --- tests/layout.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/layout.cpp b/tests/layout.cpp index 3f33e9ea1..60376099a 100644 --- a/tests/layout.cpp +++ b/tests/layout.cpp @@ -85,6 +85,24 @@ TEST_CASE("TextLayout") { ncplane_destroy(sp); } + // ensure we're honoring newlines + SUBCASE("LayoutNewlines") { + auto sp = ncplane_new(nc_, 5, 5, 0, 0, nullptr); + REQUIRE(sp); + const char boundstr[] = "a\nb\nc\nd\ne"; + size_t bytes; + CHECK(0 < ncplane_puttext(sp, 0, NCALIGN_LEFT, boundstr, &bytes)); + CHECK(0 == notcurses_render(nc_)); + CHECK(bytes == strlen(boundstr)); + char* line = ncplane_contents(sp, 0, 0, -1, -1); + REQUIRE(line); +fprintf(stderr, "LINE: [%s]\n", line); +sleep(5); + CHECK(0 == strcmp(line, "a b c d e")); + free(line); + ncplane_destroy(sp); + } + // lay out text where a wide word crosses the boundary SUBCASE("LayoutCrossBoundaryWide") { if(enforce_utf8()){