test coverage
This commit is contained in:
parent
54db58d362
commit
3b95608233
23 changed files with 199 additions and 50 deletions
32
test/escape.c
Normal file
32
test/escape.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
int getchar();
|
||||
int putchar(int ch);
|
||||
int printf(char* format, ...);
|
||||
|
||||
int main() {
|
||||
int ch;
|
||||
while ((ch = getchar()) != -1) {
|
||||
if (ch == '\\') {
|
||||
ch = getchar();
|
||||
if (ch == 'n') {
|
||||
ch = '\n';
|
||||
} else if (ch == 't') {
|
||||
ch = '\t';
|
||||
} else if (ch == 'r') {
|
||||
ch = '\r';
|
||||
} else if (ch == '0') {
|
||||
ch = '\0';
|
||||
} else if (ch == '\\') {
|
||||
ch = '\\';
|
||||
} else if (ch == '\'') {
|
||||
ch = '\'';
|
||||
} else if (ch == '\"') {
|
||||
ch = '\"';
|
||||
} else {
|
||||
printf("unexpected escaped character: '\\%c'\n", ch);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
putchar(ch);
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue