changeset 8388:9109c8dc02e1

Tests for module 'fseterr'.
author Bruno Haible <bruno@clisp.org>
date Fri, 09 Mar 2007 00:55:00 +0000
parents 1ce2ba0b442c
children e7c9cf0455da
files ChangeLog modules/fseterr-tests tests/test-fseterr.c
diffstat 3 files changed, 59 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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.
new file mode 100644
--- /dev/null
+++ b/modules/fseterr-tests
@@ -0,0 +1,11 @@
+Files:
+tests/test-fseterr.c
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-fseterr
+check_PROGRAMS += test-fseterr
+
new file mode 100644
--- /dev/null
+++ b/tests/test-fseterr.c
@@ -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;
+}