diff options
Diffstat (limited to 'stdio-common/tst-ungetc.c')
-rw-r--r-- | stdio-common/tst-ungetc.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/stdio-common/tst-ungetc.c b/stdio-common/tst-ungetc.c index 08819b7765..2cadf1cdaa 100644 --- a/stdio-common/tst-ungetc.c +++ b/stdio-common/tst-ungetc.c @@ -18,6 +18,7 @@ main (int argc, char *argv[]) FILE *fp = NULL; int retval = 0; int c; + char buffer[64]; name = tmpnam (NULL); fp = fopen (name, "w"); @@ -40,6 +41,17 @@ main (int argc, char *argv[]) assert (feof (fp) == 0); assert (getc (fp) == c); assert (getc (fp) == EOF); + fclose (fp); + fp = NULL; + + fp = fopen (name, "r"); + assert (fp != NULL); + assert (getc (fp) == 'b'); + assert (getc (fp) == 'l'); + assert (ungetc ('b', fp) == 'b'); + assert (fread (buffer, 1, 64, fp) == 2); + assert (buffer[0] == 'b'); + assert (buffer[1] == 'a'); the_end: if (fp != NULL) |