more tests

This commit is contained in:
Yaossg 2025-03-09 22:28:36 +08:00
parent d0f8b3e0ad
commit 1bcff515b7
22 changed files with 191 additions and 58 deletions

35
test/io/escape.c Normal file
View file

@ -0,0 +1,35 @@
int offset = 0;
int get() {
return "hello\\n\\tworld\\\\\\'\\\"\\0\r\t\0"[offset++];
}
int putchar(int ch);
int main() {
char ch;
while ((ch = get()) != 0) {
if (ch == '\\') {
ch = get();
if (ch == 'n') {
ch = '\n';
} else if (ch == 't') {
ch = '\t';
} else if (ch == 'r') {
ch = '\r';
} else if (ch == '0') {
break;
} else if (ch == '\\') {
ch = '\\';
} else if (ch == '\'') {
ch = '\'';
} else if (ch == '\"') {
ch = '\"';
} else {
break;
}
}
putchar(ch);
}
return 0;
}