1
0
mirror of https://git.savannah.gnu.org/git/gnulib.git synced 2025-08-08 17:22:05 +03:00

vzprintf-gnu: Add tests.

* tests/test-printf-gnu.h (test_function): Use RETTYPE instead of 'int'.
* tests/test-printf-gnu.c (RETTYPE): New macro.
* tests/test-vprintf-gnu.c (RETTYPE): New macro.
* tests/test-vzprintf-gnu.c: New file, based on
tests/test-vprintf-gnu.c.
* tests/test-vzprintf-gnu.sh: New file, based on
tests/test-vprintf-gnu.sh.
* modules/vzprintf-gnu-tests: New file.
This commit is contained in:
Bruno Haible
2024-06-30 23:04:37 +02:00
parent cb5dabfd8a
commit c630fd2fce
7 changed files with 94 additions and 3 deletions

View File

@@ -1,5 +1,15 @@
2024-06-30 Bruno Haible <bruno@clisp.org>
vzprintf-gnu: Add tests.
* tests/test-printf-gnu.h (test_function): Use RETTYPE instead of 'int'.
* tests/test-printf-gnu.c (RETTYPE): New macro.
* tests/test-vprintf-gnu.c (RETTYPE): New macro.
* tests/test-vzprintf-gnu.c: New file, based on
tests/test-vprintf-gnu.c.
* tests/test-vzprintf-gnu.sh: New file, based on
tests/test-vprintf-gnu.sh.
* modules/vzprintf-gnu-tests: New file.
vzprintf-gnu: New module.
* modules/vzprintf-gnu: New file.

View File

@@ -0,0 +1,14 @@
Files:
tests/test-vzprintf-gnu.sh
tests/test-vzprintf-gnu.c
tests/test-printf-gnu.h
tests/test-printf-gnu.output
tests/macros.h
Depends-on:
configure.ac:
Makefile.am:
TESTS += test-vzprintf-gnu.sh
check_PROGRAMS += test-vzprintf-gnu

View File

@@ -25,6 +25,7 @@
#include "macros.h"
#define RETTYPE int
#include "test-printf-gnu.h"
int

View File

@@ -1,4 +1,4 @@
/* Test of POSIX and GNU compatible vprintf() and printf() functions.
/* Test of POSIX and GNU compatible [v][z]printf() functions.
Copyright (C) 2007-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -17,7 +17,7 @@
/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
static void
test_function (int (*my_printf) (const char *, ...))
test_function (RETTYPE (*my_printf) (const char *, ...))
{
/* Here we don't test output that may be platform dependent.
The bulk of the tests is done as part of the 'vasnprintf-posix' module. */

View File

@@ -1,4 +1,4 @@
/* Test of POSIX and GNU compatible vfprintf() function.
/* Test of POSIX and GNU compatible vprintf() function.
Copyright (C) 2007-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -26,6 +26,7 @@
#include "macros.h"
#define RETTYPE int
#include "test-printf-gnu.h"
static int

49
tests/test-vzprintf-gnu.c Normal file
View File

@@ -0,0 +1,49 @@
/* Test of POSIX and GNU compatible vzprintf() function.
Copyright (C) 2007-2024 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 <https://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
#include <config.h>
#include <stdio.h>
#include <stdarg.h>
#include <stddef.h>
#include <string.h>
#include "macros.h"
#define RETTYPE off64_t
#include "test-printf-gnu.h"
static off64_t
my_zprintf (const char *format, ...)
{
va_list args;
off64_t ret;
va_start (args, format);
ret = vzprintf (format, args);
va_end (args);
return ret;
}
int
main (int argc, char *argv[])
{
test_function (my_zprintf);
return test_exit_status;
}

16
tests/test-vzprintf-gnu.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/sh
tmpfiles=""
trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
tmpfiles="$tmpfiles t-vzprintf-gnu.tmp t-vzprintf-gnu.out"
${CHECKER} ./test-vzprintf-gnu${EXEEXT} > t-vzprintf-gnu.tmp || exit 1
LC_ALL=C tr -d '\r' < t-vzprintf-gnu.tmp > t-vzprintf-gnu.out || exit 1
: "${DIFF=diff}"
${DIFF} "${srcdir}/test-printf-gnu.output" t-vzprintf-gnu.out
result=$?
rm -fr $tmpfiles
exit $result