mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 09:09:03 -04:00
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.
This commit is contained in:
parent
bd7bf65c62
commit
a3323fb22c
BIN
data/fractalheight.png
Normal file
BIN
data/fractalheight.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 129 KiB |
5
rust/notcurses/stdout.c
Normal file
5
rust/notcurses/stdout.c
Normal file
@ -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"
|
||||
|
39
src/tetris/main.h
Normal file
39
src/tetris/main.h
Normal file
@ -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…
x
Reference in New Issue
Block a user