diff options
author | Eric Blake <ebb9@byu.net> | 2007-12-13 14:58:44 -0700 |
---|---|---|
committer | Eric Blake <ebb9@byu.net> | 2007-12-13 15:01:58 -0700 |
commit | 661445a1c0cf9197442b7d25270d4fbdcd14fb5a (patch) | |
tree | 59873e4fa892900716bbbb885031385eb3df30d5 /tests/test-fseeko.c | |
parent | c094ca2425ec5622fdf023088efee54bac29fc8a (diff) | |
download | gnulib-661445a1c0cf9197442b7d25270d4fbdcd14fb5a.tar.gz |
Another fseek test.
* tests/test-fseek.c (main): Also test ungetc handling.
* tests/test-fseeko.c (main): Likewise.
* modules/fseeko (Depends-on): Add verify.
* lib/fseeko.c [!HAVE_FSEEKO]: Verify that off_t is not too
large.
Reported by Larry Jones.
Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'tests/test-fseeko.c')
-rw-r--r-- | tests/test-fseeko.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/test-fseeko.c b/tests/test-fseeko.c index 3be4f6e502..25289cef06 100644 --- a/tests/test-fseeko.c +++ b/tests/test-fseeko.c @@ -26,7 +26,7 @@ int main (int argc, char **argv) { - /* Assume stdin is seekable iff argc > 1. */ + /* Assume stdin is non-empty and seekable iff argc > 1. */ int expected = argc > 1 ? 0 : -1; /* Exit with success only if fseek/fseeko agree. */ int r1 = fseeko (stdin, (off_t)0, SEEK_CUR); @@ -35,11 +35,17 @@ main (int argc, char **argv) return 1; if (argc > 1) { - /* Test that fseek resets end-of-file marker. */ + /* Test that fseek discards ungetc data. */ + int ch = fgetc (stdin); + if (ch == EOF) + return 1; + if (ungetc (ch ^ 0xff, stdin) != (ch ^ 0xff)) + return 1; if (fseeko (stdin, (off_t) 0, SEEK_END)) return 1; if (fgetc (stdin) != EOF) return 1; + /* Test that fseek resets end-of-file marker. */ if (!feof (stdin)) return 1; if (fseeko (stdin, (off_t) 0, SEEK_END)) |