Tests for module 'fseterr'.
authorBruno Haible <bruno@clisp.org>
Fri, 9 Mar 2007 00:55:00 +0000 (00:55 +0000)
committerBruno Haible <bruno@clisp.org>
Fri, 9 Mar 2007 00:55:00 +0000 (00:55 +0000)
ChangeLog
modules/fseterr-tests [new file with mode: 0644]
tests/test-fseterr.c [new file with mode: 0644]

index 8b308c1..9fcb2f9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2007-03-08  Bruno Haible  <bruno@clisp.org>
 
+       * modules/fseterr-tests: New file.
+       * tests/test-fseterr.c: New file.
+
        * modules/fseterr: New file.
        * lib/fseterr.h: New file.
        * lib/fseterr.c: New file.
diff --git a/modules/fseterr-tests b/modules/fseterr-tests
new file mode 100644 (file)
index 0000000..ce2332f
--- /dev/null
@@ -0,0 +1,11 @@
+Files:
+tests/test-fseterr.c
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-fseterr
+check_PROGRAMS += test-fseterr
+
diff --git a/tests/test-fseterr.c b/tests/test-fseterr.c
new file mode 100644 (file)
index 0000000..966b2f9
--- /dev/null
@@ -0,0 +1,45 @@
+/* Test setting the error indicator of a stream.
+   Copyright (C) 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 2, 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, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
+
+#include <config.h>
+
+#include "fseterr.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main ()
+{
+  /* All streams are initially created with the error indicator cleared.  */
+  if (ferror (stdout))
+    abort ();
+
+  /* Verify that fseterr() works.  */
+  fseterr (stdout);
+  if (!ferror (stdout))
+    abort ();
+
+  /* Verify fseterr's effect can be undone by clearerr().  */
+  clearerr (stdout);
+  if (ferror (stdout))
+    abort ();
+
+  return 0;
+}