]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Test the __fpending function.
authorJim Meyering <jim@meyering.net>
Sun, 5 Dec 2004 19:28:15 +0000 (19:28 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 5 Dec 2004 19:28:15 +0000 (19:28 +0000)
This ensures that if there is an error in the definition of the
PENDING_OUTPUT_N_BYTES expression, we'll find about it right away;
that value is used only in the rare event that close_stdout's
fclose fails with EBADF.

lib/t-fpending.c [new file with mode: 0644]

diff --git a/lib/t-fpending.c b/lib/t-fpending.c
new file mode 100644 (file)
index 0000000..10335cd
--- /dev/null
@@ -0,0 +1,24 @@
+/* Ensure that __fpending works.  */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "__fpending.h"
+
+int
+main ()
+{
+  if (__fpending (stdout) != 0)
+    abort ();
+
+  fputs ("foo", stdout);
+  if (__fpending (stdout) != 3)
+    abort ();
+
+  fflush (stdout);
+  if (__fpending (stdout) != 0)
+    abort ();
+
+  exit (0);
+}