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

index 8ed30e0..b3ed20e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2007-03-08  Bruno Haible  <bruno@clisp.org>
 
+       * modules/fprintf-posix-tests: New file.
+       * tests/test-fprintf-posix.sh: New file.
+       * tests/test-fprintf-posix.c: New file.
+
        * modules/fprintf-posix: New file.
        * lib/fprintf.c: New file.
        * m4/fprintf-posix.m4: New file.
diff --git a/modules/fprintf-posix-tests b/modules/fprintf-posix-tests
new file mode 100644 (file)
index 0000000..4e45cba
--- /dev/null
@@ -0,0 +1,16 @@
+Files:
+tests/test-fprintf-posix.sh
+tests/test-fprintf-posix.c
+tests/test-fprintf-posix.h
+tests/test-fprintf-posix.out
+
+Depends-on:
+stdint
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-fprintf-posix.sh
+TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='$(srcdir)'
+check_PROGRAMS += test-fprintf-posix
+EXTRA_DIST += test-fprintf-posix.sh test-fprintf-posix.h test-fprintf-posix.out
diff --git a/tests/test-fprintf-posix.c b/tests/test-fprintf-posix.c
new file mode 100644 (file)
index 0000000..00402f6
--- /dev/null
@@ -0,0 +1,41 @@
+/* Test of POSIX compatible fprintf() function.
+   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.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define ASSERT(expr) if (!(expr)) abort ();
+
+#include "test-fprintf-posix.h"
+
+int
+main (int argc, char *argv[])
+{
+  test_function (fprintf);
+  return 0;
+}
diff --git a/tests/test-fprintf-posix.sh b/tests/test-fprintf-posix.sh
new file mode 100755 (executable)
index 0000000..c21cc4d
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles t-fprintf-posix.tmp"
+./test-fprintf-posix${EXEEXT} > t-fprintf-posix.tmp || exit 1
+
+: ${DIFF=diff}
+${DIFF} "${srcdir}/test-fprintf-posix.out" t-fprintf-posix.tmp
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result