mirror of
https://git.savannah.gnu.org/git/gnulib.git
synced 2025-08-08 17:22:05 +03:00
Tests for module 'xprintf-posix'.
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
2007-10-30 Bruno Haible <bruno@clisp.org>
|
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.
|
* modules/xprintf-posix: New file.
|
||||||
|
|
||||||
2007-10-30 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
|
2007-10-30 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
|
||||||
|
18
modules/xprintf-posix-tests
Normal file
18
modules/xprintf-posix-tests
Normal file
@@ -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
|
52
tests/test-xfprintf-posix.c
Normal file
52
tests/test-xfprintf-posix.c
Normal file
@@ -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;
|
||||||
|
}
|
51
tests/test-xprintf-posix.c
Normal file
51
tests/test-xprintf-posix.c
Normal file
@@ -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;
|
||||||
|
}
|
24
tests/test-xprintf-posix.sh
Executable file
24
tests/test-xprintf-posix.sh
Executable file
@@ -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
|
Reference in New Issue
Block a user