Enforce UTF8 where necessary in unit tests #428

Certain unit tests required UTF8 encoding on the output
terminal to work (#428). This includes anything which does
any kind of fill. Add enforce_utf8() checks to all such
tests that were missing them. Unit tests once again pass in
a pure ASCII environment.
pull/433/head
nick black 4 years ago
parent bd7bf65c62
commit a3323fb22c
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

@ -0,0 +1,5 @@
#include <stdio.h>
FILE* libc_stdout(void){
return stdout;
}

@ -88,42 +88,4 @@ private:
};
int main(void) {
if(setlocale(LC_ALL, "") == nullptr){
return EXIT_FAILURE;
}
srand(time(NULL));
std::atomic_bool gameover = false;
notcurses_options ncopts{};
ncpp::NotCurses nc(ncopts);
Tetris t{nc, gameover};
std::thread tid(&Tetris::Ticker, &t);
ncpp::Plane* stdplane = nc.get_stdplane();
char32_t input = 0;
ncinput ni;
while(!gameover && (input = nc.getc(true, &ni)) != (char32_t)-1){
if(input == 'q'){
break;
}
switch(input){
case NCKEY_LEFT: case 'h': t.MoveLeft(); break;
case NCKEY_RIGHT: case 'l': t.MoveRight(); break;
case NCKEY_DOWN: case 'j': t.MoveDown(); break;
case 'L': if(ni.ctrl){ notcurses_refresh(nc); } break;
case 'z': t.RotateCcw(); break;
case 'x': t.RotateCw(); break;
default:
stdplane->cursor_move(0, 0);
stdplane->printf("Got unknown input U+%06x", input);
nc.render();
break;
}
}
if(gameover || input == 'q'){ // FIXME signal it on 'q'
gameover = true;
tid.join();
}else{
return EXIT_FAILURE;
}
return nc.stop() ? EXIT_SUCCESS : EXIT_FAILURE;
}
#include "main.h"

@ -0,0 +1,39 @@
int main(void) {
if(setlocale(LC_ALL, "") == nullptr){
return EXIT_FAILURE;
}
srand(time(NULL));
std::atomic_bool gameover = false;
notcurses_options ncopts{};
ncpp::NotCurses nc(ncopts);
Tetris t{nc, gameover};
std::thread tid(&Tetris::Ticker, &t);
ncpp::Plane* stdplane = nc.get_stdplane();
char32_t input = 0;
ncinput ni;
while(!gameover && (input = nc.getc(true, &ni)) != (char32_t)-1){
if(input == 'q'){
break;
}
switch(input){
case NCKEY_LEFT: case 'h': t.MoveLeft(); break;
case NCKEY_RIGHT: case 'l': t.MoveRight(); break;
case NCKEY_DOWN: case 'j': t.MoveDown(); break;
case 'L': if(ni.ctrl){ notcurses_refresh(nc); } break;
case 'z': t.RotateCcw(); break;
case 'x': t.RotateCw(); break;
default:
stdplane->cursor_move(0, 0);
stdplane->printf("Got unknown input U+%06x", input);
nc.render();
break;
}
}
if(gameover || input == 'q'){ // FIXME signal it on 'q'
gameover = true;
tid.join();
}else{
return EXIT_FAILURE;
}
return nc.stop() ? EXIT_SUCCESS : EXIT_FAILURE;
}

@ -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;

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

@ -28,6 +28,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;

@ -9,6 +9,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;

Loading…
Cancel
Save