mirror of
https://https.git.savannah.gnu.org/git/gnulib.git
synced 2026-09-01 02:34:55 +00:00
Test for internationalization of module 'vasnprintf-posix'.
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
2007-03-09 Bruno Haible <bruno@clisp.org>
|
||||
|
||||
* tests/test-vasnprintf-posix2.sh: New file.
|
||||
* tests/test-vasnprintf-posix2.c: New file.
|
||||
* modules/vasnprintf-posix-tests (Files): Add them and m4/locale-fr.m4.
|
||||
(configure.ac): Invoke gt_LOCALE_FR and gt_LOCALE_FR_UTF8.
|
||||
(Makefile.am): Activate test-vasnprintf-posix2.sh.
|
||||
|
||||
* lib/vasnprintf.c (VASNPRINTF): For the 'a' and 'A' directives, use
|
||||
a locale dependent decimal point, rather than always '.'.
|
||||
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
Files:
|
||||
tests/test-vasnprintf-posix.c
|
||||
tests/test-vasnprintf-posix2.sh
|
||||
tests/test-vasnprintf-posix2.c
|
||||
m4/longdouble.m4
|
||||
m4/locale-fr.m4
|
||||
|
||||
Depends-on:
|
||||
stdint
|
||||
|
||||
configure.ac:
|
||||
AC_REQUIRE([gt_TYPE_LONGDOUBLE])
|
||||
gt_LOCALE_FR
|
||||
gt_LOCALE_FR_UTF8
|
||||
|
||||
Makefile.am:
|
||||
TESTS += test-vasnprintf-posix
|
||||
check_PROGRAMS += test-vasnprintf-posix
|
||||
|
||||
TESTS += test-vasnprintf-posix test-vasnprintf-posix2.sh
|
||||
TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
|
||||
check_PROGRAMS += test-vasnprintf-posix test-vasnprintf-posix2
|
||||
EXTRA_DIST += test-vasnprintf-posix2.sh
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/* Test of POSIX compatible vasnprintf() and asnprintf() functions.
|
||||
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 "vasnprintf.h"
|
||||
|
||||
#include <locale.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define ASSERT(expr) if (!(expr)) abort ();
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
/* configure should already have checked that the locale is supported. */
|
||||
if (setlocale (LC_ALL, "") == NULL)
|
||||
return 1;
|
||||
|
||||
/* Test that a locale dependent decimal point is used. */
|
||||
{
|
||||
size_t length;
|
||||
char *result = asnprintf (NULL, &length, "%.1a", 1.0);
|
||||
ASSERT (result != NULL);
|
||||
ASSERT (strcmp (result, "0x1,0p+0") == 0
|
||||
|| strcmp (result, "0x2,0p-1") == 0
|
||||
|| strcmp (result, "0x4,0p-2") == 0
|
||||
|| strcmp (result, "0x8,0p-3") == 0);
|
||||
ASSERT (length == strlen (result));
|
||||
free (result);
|
||||
}
|
||||
|
||||
#if HAVE_LONG_DOUBLE
|
||||
|
||||
/* Test that a locale dependent decimal point is used. */
|
||||
{
|
||||
size_t length;
|
||||
char *result = asnprintf (NULL, &length, "%.1La", 1.0L);
|
||||
ASSERT (result != NULL);
|
||||
ASSERT (strcmp (result, "0x1,0p+0") == 0
|
||||
|| strcmp (result, "0x2,0p-1") == 0
|
||||
|| strcmp (result, "0x4,0p-2") == 0
|
||||
|| strcmp (result, "0x8,0p-3") == 0);
|
||||
ASSERT (length == strlen (result));
|
||||
free (result);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Test whether a french locale is installed.
|
||||
: ${LOCALE_FR=fr_FR}
|
||||
: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
|
||||
if test $LOCALE_FR != none; then
|
||||
testlocale=$LOCALE_FR
|
||||
else
|
||||
if test $LOCALE_FR_UTF8 != none; then
|
||||
testlocale=$LOCALE_FR_UTF8
|
||||
else
|
||||
if test -f /usr/bin/localedef; then
|
||||
echo "Skipping test: no french locale is installed"
|
||||
else
|
||||
echo "Skipping test: no french locale is supported"
|
||||
fi
|
||||
exit 77
|
||||
fi
|
||||
fi
|
||||
|
||||
LC_ALL=$testlocale \
|
||||
./test-vasnprintf-posix2${EXEEXT}
|
||||
Reference in New Issue
Block a user