From: Bruno Haible <bruno@clisp.org>
Date: Sun, 7 Oct 2007 02:48:29 +0000 (+0200)
Subject: Test for module 'freopen'.
X-Git-Tag: v0.0~121
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=36bde9b7b3c5d8a41015ac2be74488b83d27ed41;p=gnulib.git

Test for module 'freopen'.
---

diff --git a/ChangeLog b/ChangeLog
index f895211c78..6b8276c4fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2007-10-06  Bruno Haible  <bruno@clisp.org>
 
+	* modules/freopen-tests: New file.
+	* tests/test-freopen.c: New file.
+
 	* modules/fopen-tests: New file.
 	* tests/test-fopen.c: New file.
 
diff --git a/modules/freopen-tests b/modules/freopen-tests
new file mode 100644
index 0000000000..dd232cf255
--- /dev/null
+++ b/modules/freopen-tests
@@ -0,0 +1,11 @@
+Files:
+tests/test-freopen.c
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-freopen
+check_PROGRAMS += test-freopen
+
diff --git a/tests/test-freopen.c b/tests/test-freopen.c
new file mode 100644
index 0000000000..be30af1042
--- /dev/null
+++ b/tests/test-freopen.c
@@ -0,0 +1,42 @@
+/* Test of opening a file 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 <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 (freopen ("/dev/null", "r", stdin) != NULL);
+
+  return 0;
+}