From d9bb9b03af0da641312887d6cd63e36e98d9d656 Mon Sep 17 00:00:00 2001 From: nick black Date: Mon, 11 May 2020 04:57:20 -0400 Subject: [PATCH] notcurses-tester: run passing tests in C locale #325 --- tests/cell.cpp | 3 +++ tests/egcpool.cpp | 4 ++++ tests/fills.cpp | 3 +++ tests/main.cpp | 3 --- tests/main.h | 3 ++- tests/ncplane.cpp | 3 +++ tests/plot.cpp | 3 +++ tests/reader.cpp | 6 +++++- tests/rotate.cpp | 3 +++ tests/visual.cpp | 3 +++ tests/wide.cpp | 3 +++ 11 files changed, 32 insertions(+), 5 deletions(-) diff --git a/tests/cell.cpp b/tests/cell.cpp index a9ddd5774..30e6275ee 100644 --- a/tests/cell.cpp +++ b/tests/cell.cpp @@ -2,6 +2,9 @@ #include "egcpool.h" TEST_CASE("MultibyteWidth") { + if(!enforce_utf8()){ + return; + } CHECK(0 == mbswidth("")); // zero bytes, zero columns CHECK(-1 == mbswidth("\x7")); // single byte, non-printable CHECK(1 == mbswidth(" ")); // single byte, one column diff --git a/tests/egcpool.cpp b/tests/egcpool.cpp index 0f0dfc16a..4be9234e6 100644 --- a/tests/egcpool.cpp +++ b/tests/egcpool.cpp @@ -12,6 +12,10 @@ TEST_CASE("EGCpool") { CHECK(!pool_.poolused); } + if(!enforce_utf8()){ + return; + } + SUBCASE("UTF8EGC") { const char* wstr = "☢"; int c; diff --git a/tests/fills.cpp b/tests/fills.cpp index 81888ce0e..5ff5466ae 100644 --- a/tests/fills.cpp +++ b/tests/fills.cpp @@ -7,6 +7,9 @@ TEST_CASE("Fills") { if(getenv("TERM") == nullptr){ return; } + if(!enforce_utf8()){ + return; + } notcurses_options nopts{}; nopts.inhibit_alternate_screen = true; nopts.suppress_banner = true; diff --git a/tests/main.cpp b/tests/main.cpp index 34df7aa14..506bbea0e 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -86,9 +86,6 @@ auto main(int argc, const char **argv) -> int { std::cerr << "Coudln't set locale based on user preferences!" << std::endl; return EXIT_FAILURE; } - if(!enforce_utf8()){ - return EXIT_SUCCESS; // hrmmm - } doctest::Context context; context.setOption("order-by", "name"); // sort the test cases by their name diff --git a/tests/main.h b/tests/main.h index 5f3435fae..0ba9abdc5 100644 --- a/tests/main.h +++ b/tests/main.h @@ -6,6 +6,7 @@ #include "version.h" #include -char* find_data(const char* datum); +auto find_data(const char* datum) -> char*; +auto enforce_utf8() -> bool; #endif diff --git a/tests/ncplane.cpp b/tests/ncplane.cpp index 95c4d1a26..51cc5b899 100644 --- a/tests/ncplane.cpp +++ b/tests/ncplane.cpp @@ -21,6 +21,9 @@ TEST_CASE("NCPlane") { if(getenv("TERM") == nullptr){ return; } + if(!enforce_utf8()){ + return; + } notcurses_options nopts{}; nopts.inhibit_alternate_screen = true; nopts.suppress_banner = true; diff --git a/tests/plot.cpp b/tests/plot.cpp index b7faa8a7a..c6ceb16c2 100644 --- a/tests/plot.cpp +++ b/tests/plot.cpp @@ -7,6 +7,9 @@ TEST_CASE("Plot") { if(getenv("TERM") == nullptr){ return; } + if(!enforce_utf8()){ + return; + } notcurses_options nopts{}; nopts.inhibit_alternate_screen = true; nopts.suppress_banner = true; diff --git a/tests/reader.cpp b/tests/reader.cpp index e1dbdd36f..1a8808109 100644 --- a/tests/reader.cpp +++ b/tests/reader.cpp @@ -34,7 +34,11 @@ TEST_CASE("Readers") { ncreader_options opts{}; opts.physrows = dimy / 2; opts.physcols = dimx / 2; - opts.egc = strdup("▒"); + if(enforce_utf8()){ + opts.egc = strdup("▒"); + }else{ + opts.egc = strdup("x"); + } auto nr = ncreader_create(n_, 0, 0, &opts); REQUIRE(nullptr != nr); channels_set_fg(&opts.echannels, 0xff44ff); diff --git a/tests/rotate.cpp b/tests/rotate.cpp index 70e321edc..0473b8e63 100644 --- a/tests/rotate.cpp +++ b/tests/rotate.cpp @@ -30,6 +30,9 @@ TEST_CASE("Rotate") { if(getenv("TERM") == nullptr){ return; } + if(!enforce_utf8()){ + return; + } notcurses_options nopts{}; nopts.inhibit_alternate_screen = true; nopts.suppress_banner = true; diff --git a/tests/visual.cpp b/tests/visual.cpp index e32cc0372..95de7662d 100644 --- a/tests/visual.cpp +++ b/tests/visual.cpp @@ -5,6 +5,9 @@ TEST_CASE("Multimedia") { if(getenv("TERM") == nullptr){ return; } + if(!enforce_utf8()){ + return; + } notcurses_options nopts{}; nopts.inhibit_alternate_screen = true; nopts.suppress_banner = true; diff --git a/tests/wide.cpp b/tests/wide.cpp index d5011897e..f477ac07b 100644 --- a/tests/wide.cpp +++ b/tests/wide.cpp @@ -7,6 +7,9 @@ TEST_CASE("Wide") { if(getenv("TERM") == nullptr){ return; } + if(!enforce_utf8()){ + return; + } notcurses_options nopts{}; nopts.inhibit_alternate_screen = true; nopts.suppress_banner = true;