Added some tests for stdio

This commit is contained in:
Tom Almeida
2018-03-15 15:28:14 +08:00
parent 7f2b720962
commit b0492eba84
7 changed files with 45 additions and 0 deletions
+3
View File
@@ -15,6 +15,7 @@
/fsync
/ftruncate
/getid
/getc_unget
/link
/math
/mem
@@ -27,6 +28,8 @@
/sprintf
/stdlib/strtol
/stdlib/a64l
/stdio/fwrite
/stdio/all
/string/strncmp
/string/strcspn
/string/strchr
+4
View File
@@ -12,6 +12,8 @@ EXPECT_BINS=\
fcntl \
fsync \
ftruncate \
getid \
getc_unget \
link \
math \
mem \
@@ -20,6 +22,8 @@ EXPECT_BINS=\
rmdir \
sleep \
sprintf \
stdio/fwrite \
stdio/all \
stdlib/strtol \
stdlib/a64l \
string/strncmp \
+12
View File
@@ -0,0 +1,12 @@
#include <stdio.h>
int main(int argc, char ** argv) {
ungetc('h', stdin);
char c;
if ((c = getchar()) == 'h') {
printf("Worked!\n");
return 0;
}
printf("failed :( %c\n", c);
return 0;
}
+11
View File
@@ -0,0 +1,11 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char ** argv) {
FILE *f = fopen("stdio/stdio.in", "r");
printf("%c\n", fgetc(f));
ungetc('H', f);
char *in = malloc(30);
printf("%s\n", fgets(in, 30, f));
return 0;
}
+11
View File
@@ -0,0 +1,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
int main(int argc, char ** argv) {
FILE *f = fopen("stdio/fwrite.out", "w");
char *in = "Hello World!";
fputs(in, f); // calls fwrite, helpers::fwritex, internal::to_write and internal::stdio_write
fclose(f);
return 0;
}
+1
View File
@@ -0,0 +1 @@
Hello World!
+3
View File
@@ -0,0 +1,3 @@
Hello World!
Line 2