|
Packit Service |
82fcde |
/* Testing the implementation of strfmon(3).
|
|
Packit Service |
82fcde |
Copyright (C) 1996-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
Contributed by Jochen Hein <jochen.hein@delphi.central.de>, 1997.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library; if not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <stdio.h>
|
|
Packit Service |
82fcde |
#include <locale.h>
|
|
Packit Service |
82fcde |
#include <monetary.h>
|
|
Packit Service |
82fcde |
#include <string.h>
|
|
Packit Service |
82fcde |
#include <stdlib.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/*
|
|
Packit Service |
82fcde |
test-strfmon gets called with three parameters:
|
|
Packit Service |
82fcde |
- the locale
|
|
Packit Service |
82fcde |
- the format-string to be used
|
|
Packit Service |
82fcde |
- the actual number to be formatted
|
|
Packit Service |
82fcde |
- the expected string
|
|
Packit Service |
82fcde |
If the test passes, test-strfmon terminates with returncode 0,
|
|
Packit Service |
82fcde |
otherwise with 1
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
#define EXIT_SUCCESS 0
|
|
Packit Service |
82fcde |
#define EXIT_FAILURE 1
|
|
Packit Service |
82fcde |
#define EXIT_SETLOCALE 2
|
|
Packit Service |
82fcde |
#define EXIT_STRFMON 3
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
int
|
|
Packit Service |
82fcde |
main (int argc, char *argv[])
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
char s[200];
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
if (setlocale (LC_MONETARY, argv[1]) == NULL)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
fprintf (stderr, "setlocale(LC_MONETARY, \"%s\"): %m\n", argv[1]);
|
|
Packit Service |
82fcde |
exit (EXIT_SETLOCALE);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
if (strfmon (s, sizeof (s), argv[2], (double) atof (argv[3])) == -1)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
perror ("strfmon");
|
|
Packit Service |
82fcde |
exit (EXIT_STRFMON);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
if (strcmp (s, argv[4]) != 0)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("\
|
|
Packit Service |
82fcde |
Locale: \"%s\" Format: \"%s\" Value: \"%s\" Received: \"%s\" Expected: \"%s\" => %s\n",
|
|
Packit Service |
82fcde |
argv[1], argv[2], argv[3], s, argv[4],
|
|
Packit Service |
82fcde |
strcmp (s, argv[4]) != 0 ? "false" : "correct");
|
|
Packit Service |
82fcde |
exit (EXIT_FAILURE);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
return EXIT_SUCCESS;
|
|
Packit Service |
82fcde |
}
|