notcurses-tester: run passing tests in C locale #325

This commit is contained in:
nick black 2020-05-11 04:57:20 -04:00 committed by Nick Black
parent 7dae248a41
commit d9bb9b03af
11 changed files with 32 additions and 5 deletions

View File

@ -2,6 +2,9 @@
#include "egcpool.h" #include "egcpool.h"
TEST_CASE("MultibyteWidth") { TEST_CASE("MultibyteWidth") {
if(!enforce_utf8()){
return;
}
CHECK(0 == mbswidth("")); // zero bytes, zero columns CHECK(0 == mbswidth("")); // zero bytes, zero columns
CHECK(-1 == mbswidth("\x7")); // single byte, non-printable CHECK(-1 == mbswidth("\x7")); // single byte, non-printable
CHECK(1 == mbswidth(" ")); // single byte, one column CHECK(1 == mbswidth(" ")); // single byte, one column

View File

@ -12,6 +12,10 @@ TEST_CASE("EGCpool") {
CHECK(!pool_.poolused); CHECK(!pool_.poolused);
} }
if(!enforce_utf8()){
return;
}
SUBCASE("UTF8EGC") { SUBCASE("UTF8EGC") {
const char* wstr = ""; const char* wstr = "";
int c; int c;

View File

@ -7,6 +7,9 @@ TEST_CASE("Fills") {
if(getenv("TERM") == nullptr){ if(getenv("TERM") == nullptr){
return; return;
} }
if(!enforce_utf8()){
return;
}
notcurses_options nopts{}; notcurses_options nopts{};
nopts.inhibit_alternate_screen = true; nopts.inhibit_alternate_screen = true;
nopts.suppress_banner = true; nopts.suppress_banner = true;

View File

@ -86,9 +86,6 @@ auto main(int argc, const char **argv) -> int {
std::cerr << "Coudln't set locale based on user preferences!" << std::endl; std::cerr << "Coudln't set locale based on user preferences!" << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if(!enforce_utf8()){
return EXIT_SUCCESS; // hrmmm
}
doctest::Context context; doctest::Context context;
context.setOption("order-by", "name"); // sort the test cases by their name context.setOption("order-by", "name"); // sort the test cases by their name

View File

@ -6,6 +6,7 @@
#include "version.h" #include "version.h"
#include <notcurses/notcurses.h> #include <notcurses/notcurses.h>
char* find_data(const char* datum); auto find_data(const char* datum) -> char*;
auto enforce_utf8() -> bool;
#endif #endif

View File

@ -21,6 +21,9 @@ TEST_CASE("NCPlane") {
if(getenv("TERM") == nullptr){ if(getenv("TERM") == nullptr){
return; return;
} }
if(!enforce_utf8()){
return;
}
notcurses_options nopts{}; notcurses_options nopts{};
nopts.inhibit_alternate_screen = true; nopts.inhibit_alternate_screen = true;
nopts.suppress_banner = true; nopts.suppress_banner = true;

View File

@ -7,6 +7,9 @@ TEST_CASE("Plot") {
if(getenv("TERM") == nullptr){ if(getenv("TERM") == nullptr){
return; return;
} }
if(!enforce_utf8()){
return;
}
notcurses_options nopts{}; notcurses_options nopts{};
nopts.inhibit_alternate_screen = true; nopts.inhibit_alternate_screen = true;
nopts.suppress_banner = true; nopts.suppress_banner = true;

View File

@ -34,7 +34,11 @@ TEST_CASE("Readers") {
ncreader_options opts{}; ncreader_options opts{};
opts.physrows = dimy / 2; opts.physrows = dimy / 2;
opts.physcols = dimx / 2; opts.physcols = dimx / 2;
if(enforce_utf8()){
opts.egc = strdup(""); opts.egc = strdup("");
}else{
opts.egc = strdup("x");
}
auto nr = ncreader_create(n_, 0, 0, &opts); auto nr = ncreader_create(n_, 0, 0, &opts);
REQUIRE(nullptr != nr); REQUIRE(nullptr != nr);
channels_set_fg(&opts.echannels, 0xff44ff); channels_set_fg(&opts.echannels, 0xff44ff);

View File

@ -30,6 +30,9 @@ TEST_CASE("Rotate") {
if(getenv("TERM") == nullptr){ if(getenv("TERM") == nullptr){
return; return;
} }
if(!enforce_utf8()){
return;
}
notcurses_options nopts{}; notcurses_options nopts{};
nopts.inhibit_alternate_screen = true; nopts.inhibit_alternate_screen = true;
nopts.suppress_banner = true; nopts.suppress_banner = true;

View File

@ -5,6 +5,9 @@ TEST_CASE("Multimedia") {
if(getenv("TERM") == nullptr){ if(getenv("TERM") == nullptr){
return; return;
} }
if(!enforce_utf8()){
return;
}
notcurses_options nopts{}; notcurses_options nopts{};
nopts.inhibit_alternate_screen = true; nopts.inhibit_alternate_screen = true;
nopts.suppress_banner = true; nopts.suppress_banner = true;

View File

@ -7,6 +7,9 @@ TEST_CASE("Wide") {
if(getenv("TERM") == nullptr){ if(getenv("TERM") == nullptr){
return; return;
} }
if(!enforce_utf8()){
return;
}
notcurses_options nopts{}; notcurses_options nopts{};
nopts.inhibit_alternate_screen = true; nopts.inhibit_alternate_screen = true;
nopts.suppress_banner = true; nopts.suppress_banner = true;