Mercurial > hg > octave-lyh > gnulib-hg
changeset 9428:733dbb7b0c0a
Tests for module 'xprintf-posix'.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Wed, 31 Oct 2007 02:25:22 +0100 |
parents | f5d380f2d698 |
children | 83a3e25b88a7 |
files | ChangeLog modules/xprintf-posix-tests tests/test-xfprintf-posix.c tests/test-xprintf-posix.c tests/test-xprintf-posix.sh |
diffstat | 5 files changed, 150 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2007-10-30 Bruno Haible <bruno@clisp.org> + * modules/xprintf-posix-tests: New file. + * tests/test-xprintf-posix.sh: New file. + * tests/test-xprintf-posix.c: New file. + * tests/test-xfprintf-posix.c: New file. + * modules/xprintf-posix: New file. 2007-10-30 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
new file mode 100644 --- /dev/null +++ b/modules/xprintf-posix-tests @@ -0,0 +1,18 @@ +Files: +tests/test-xprintf-posix.sh +tests/test-xfprintf-posix.c +tests/test-xprintf-posix.c +tests/test-fprintf-posix.h +tests/test-printf-posix.h +tests/test-printf-posix.output + +Depends-on: +stdint +progname + +configure.ac: + +Makefile.am: +TESTS += test-xprintf-posix.sh +TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='$(srcdir)' +check_PROGRAMS += test-xfprintf-posix test-xprintf-posix
new file mode 100644 --- /dev/null +++ b/tests/test-xfprintf-posix.c @@ -0,0 +1,52 @@ +/* Test of error-checking xfprintf() function with POSIX compatible formatting. + 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 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 Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "xprintf.h" + +#include <stdarg.h> +#include <stddef.h> +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> + +#include "progname.h" + +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) + +#include "test-fprintf-posix.h" + +int +main (int argc, char *argv[]) +{ + set_program_name (argv[0]); + + test_function (xfprintf); + return 0; +}
new file mode 100644 --- /dev/null +++ b/tests/test-xprintf-posix.c @@ -0,0 +1,51 @@ +/* Test of error-checking xprintf() function with POSIX compatible formatting. + 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 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 Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "xprintf.h" + +#include <stddef.h> +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> + +#include "progname.h" + +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) + +#include "test-printf-posix.h" + +int +main (int argc, char *argv[]) +{ + set_program_name (argv[0]); + + test_function (xprintf); + return 0; +}
new file mode 100755 --- /dev/null +++ b/tests/test-xprintf-posix.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles t-xprintf-posix.tmp t-xprintf-posix.out" +./test-xprintf-posix${EXEEXT} > t-xprintf-posix.tmp || exit 1 +tr -d '\r' < t-xprintf-posix.tmp > t-xprintf-posix.out || exit 1 + +: ${DIFF=diff} +${DIFF} "${srcdir}/test-printf-posix.output" t-xprintf-posix.out +test $? = 0 || { rm -fr $tmpfiles; exit 1; } + +tmpfiles="$tmpfiles t-xfprintf-posix.tmp t-xfprintf-posix.out" +./test-xfprintf-posix${EXEEXT} > t-xfprintf-posix.tmp || exit 1 +tr -d '\r' < t-xfprintf-posix.tmp > t-xfprintf-posix.out || exit 1 + +: ${DIFF=diff} +${DIFF} "${srcdir}/test-printf-posix.output" t-xfprintf-posix.out +test $? = 0 || { rm -fr $tmpfiles; exit 1; } + +rm -fr $tmpfiles + +exit 0