Test for __fpending function.
authorBruno Haible <bruno@clisp.org>
Wed, 3 Oct 2007 21:36:11 +0000 (23:36 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 3 Oct 2007 21:36:11 +0000 (23:36 +0200)
ChangeLog
modules/fpending-tests [new file with mode: 0644]
tests/test-fpending.c [new file with mode: 0644]

index eb7de88..37d8b80 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2007-10-03  Bruno Haible  <bruno@clisp.org>
 
+       * tests/test-fpending.c: New file, mostly copied
+       from coreutils/lib/t-fpending.c.
+       * modules/fpending-tests: New file.
+
+2007-10-03  Bruno Haible  <bruno@clisp.org>
+
        Port the stdio extensions to QNX (untested).
        * lib/fseterr.c (fseterr): Add support for QNX.
        * lib/fbufmode.c (fbufmode): Likewise.
diff --git a/modules/fpending-tests b/modules/fpending-tests
new file mode 100644 (file)
index 0000000..0338987
--- /dev/null
@@ -0,0 +1,10 @@
+Files:
+tests/test-fpending.c
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-fpending
+check_PROGRAMS += test-fpending
diff --git a/tests/test-fpending.c b/tests/test-fpending.c
new file mode 100644 (file)
index 0000000..05563f8
--- /dev/null
@@ -0,0 +1,50 @@
+/* Ensure that __fpending works.
+
+   Copyright (C) 2004, 2007 Free Software Foundation, Inc.
+
+   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 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
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   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, see <http://www.gnu.org/licenses/>.
+
+   Written by Jim Meyering.  */
+
+#include <config.h>
+
+#include "fpending.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define ASSERT(expr) \
+  do                                                                        \
+    {                                                                       \
+      if (!(expr))                                                          \
+        {                                                                   \
+          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+          abort ();                                                         \
+        }                                                                   \
+    }                                                                       \
+  while (0)
+
+int
+main ()
+{
+  ASSERT (__fpending (stdout) == 0);
+
+  fputs ("foo", stdout);
+  ASSERT (__fpending (stdout) == 3);
+
+  fflush (stdout);
+  ASSERT (__fpending (stdout) == 0);
+
+  exit (0);
+}