X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-freadahead.c;h=c369cbafd1bbd490dd8165e88e8bb50612269e3d;hb=217fb89cd467efe0ae1668ac1b69d5cc4742e79b;hp=9bc5d737665129f97039c1bfc4a409bb0fc88ca4;hpb=5bca97aedcd1e07c1bd80c242239b83c7df9194d;p=gnulib.git
diff --git a/tests/test-freadahead.c b/tests/test-freadahead.c
index 9bc5d7376..c369cbafd 100644
--- a/tests/test-freadahead.c
+++ b/tests/test-freadahead.c
@@ -1,10 +1,10 @@
/* Test of freadahead() function.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007-2008 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify
+ This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -12,8 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ along with this program. If not, see . */
/* Written by Bruno Haible , 2007. */
@@ -31,6 +30,7 @@
if (!(expr)) \
{ \
fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ fflush (stderr); \
abort (); \
} \
} \
@@ -55,8 +55,29 @@ main (int argc, char **argv)
__STDIO_BUFFERS. */
ASSERT (freadahead (stdin) == 0);
else
- /* Normal buffered stdio. */
- ASSERT (freadahead (stdin) != 0);
+ {
+ /* Normal buffered stdio. */
+ size_t buffered;
+ int c, c2;
+
+ ASSERT (freadahead (stdin) != 0);
+ buffered = freadahead (stdin);
+
+ c = fgetc (stdin);
+ ASSERT (freadahead (stdin) == buffered - 1);
+ ungetc (c, stdin);
+ ASSERT (freadahead (stdin) == buffered);
+ c2 = fgetc (stdin);
+ ASSERT (c2 == c);
+ ASSERT (freadahead (stdin) == buffered - 1);
+
+ c = '@';
+ ungetc (c, stdin);
+ ASSERT (freadahead (stdin) == buffered);
+ c2 = fgetc (stdin);
+ ASSERT (c2 == c);
+ ASSERT (freadahead (stdin) == buffered - 1);
+ }
}
return 0;