Skip to content
Snippets Groups Projects
Commit b0492eba authored by Tom Almeida's avatar Tom Almeida
Browse files

Added some tests for stdio

parent 7f2b7209
No related branches found
No related tags found
1 merge request!85Added functions for stdio.h
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
/fsync /fsync
/ftruncate /ftruncate
/getid /getid
/getc_unget
/link /link
/math /math
/mem /mem
...@@ -27,6 +28,8 @@ ...@@ -27,6 +28,8 @@
/sprintf /sprintf
/stdlib/strtol /stdlib/strtol
/stdlib/a64l /stdlib/a64l
/stdio/fwrite
/stdio/all
/string/strncmp /string/strncmp
/string/strcspn /string/strcspn
/string/strchr /string/strchr
......
...@@ -12,6 +12,8 @@ EXPECT_BINS=\ ...@@ -12,6 +12,8 @@ EXPECT_BINS=\
fcntl \ fcntl \
fsync \ fsync \
ftruncate \ ftruncate \
getid \
getc_unget \
link \ link \
math \ math \
mem \ mem \
...@@ -20,6 +22,8 @@ EXPECT_BINS=\ ...@@ -20,6 +22,8 @@ EXPECT_BINS=\
rmdir \ rmdir \
sleep \ sleep \
sprintf \ sprintf \
stdio/fwrite \
stdio/all \
stdlib/strtol \ stdlib/strtol \
stdlib/a64l \ stdlib/a64l \
string/strncmp \ string/strncmp \
......
#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;
}
#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;
}
#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;
}
Hello World!
\ No newline at end of file
Hello World!
Line 2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment