Skip to content

Commit

Permalink
Add test for unicode input/output
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenthuberdeau committed Sep 4, 2024
1 parent 4900dd5 commit eefc97b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/_all/input-output/read-unicode.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Make sure we can read unicode characters. This is to make sure the utilities
// we compile using pnut-sh can process all kind of files.
// This test is not essential for the bootstrap but being able to properly read
// non-ascii characters makes pnut more general.
//
// Yash's IO is a little bit weird and it's not a very popular shell, disabling the test for now.
// expect_failure_for: yash

#ifndef PNUT_CC
#include <stdio.h>
#else
typedef int FILE;
#endif

void putstr(const char *s) {
while (*s) {
putchar(*s);
s++;
}
}

void main() {
int i = 0;
char c;
FILE *f = fopen("tests/_all/input-output/unicode.txt", "r");
putstr("printf? 💣\n");
while ((c = fgetc(f)) != -1) {
putchar(c);
}
}
3 changes: 3 additions & 0 deletions tests/_all/input-output/read-unicode.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
printf? 💣
accents: éôèà
some emoji: 🥜
2 changes: 2 additions & 0 deletions tests/_all/input-output/unicode.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
accents: éôèà
some emoji: 🥜

0 comments on commit eefc97b

Please sign in to comment.