* [PATCH] Add long double input for strfmon test
@ 2018-06-29 10:05 Rajalakshmi Srinivasaraghavan
2018-06-29 10:25 ` Florian Weimer
0 siblings, 1 reply; 2+ messages in thread
From: Rajalakshmi Srinivasaraghavan @ 2018-06-29 10:05 UTC (permalink / raw)
To: libc-alpha; +Cc: Rajalakshmi Srinivasaraghavan
This patch adds long double type inputs in strfmon_l test
which will help in long double migration.
Tested for powerpc64le.
2018-06-29 Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
* stdlib/tst-strfmon_l.c: Add tests for long double.
---
stdlib/tst-strfmon_l.c | 38 ++++++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 10 deletions(-)
diff --git a/stdlib/tst-strfmon_l.c b/stdlib/tst-strfmon_l.c
index 1994d623eb..c43fe99256 100644
--- a/stdlib/tst-strfmon_l.c
+++ b/stdlib/tst-strfmon_l.c
@@ -70,16 +70,24 @@ static bool errors;
/* Test one value using the locale loc. */
static void
-test_one (const char *format, double value, const char *expected)
+test_one (const char *format, double value, const char *ldformat,
+ long double ldvalue, const char *expected)
{
- static char actual[64];
+ static char actual[64], actualld[64];
int result = strfmon_l (actual, sizeof (actual), loc, format, value);
+ int res_ld = strfmon_l (actualld, sizeof (actualld), loc, ldformat, ldvalue);
if (result < 0)
{
printf ("error: locale %s, format \"%s\", value %g: strfmon_l: %m\n",
loc_name, format, value);
errors = true;
}
+ else if (res_ld < 0)
+ {
+ printf ("error: locale %s, format \"%s\", value %Lg: strfmon_l: %m\n",
+ loc_name, ldformat, ldvalue);
+ errors = true;
+ }
else if (strcmp (actual, expected) != 0)
{
printf ("error: locale %s, format \"%s\", value %g: mismatch\n",
@@ -88,21 +96,31 @@ test_one (const char *format, double value, const char *expected)
printf ("error: actual: \"%s\"\n", actual);
errors = true;
}
+ else if (strcmp (actualld, expected) != 0)
+ {
+ printf ("error: locale %s, format \"%s\", value %Lg: mismatch\n",
+ loc_name, ldformat, ldvalue);
+ printf ("error: expected: \"%s\"\n", expected);
+ printf ("error: actual: \"%s\"\n", actualld);
+ errors = true;
+ }
}
static void
test_pair (const struct testcase_pair *pair)
{
double positive = 1234567.89;
- test_one ("%i", positive, pair->positive.i);
- test_one ("%n", positive, pair->positive.n);
- test_one ("%^i", positive, pair->positive.i_ungrouped);
- test_one ("%^n", positive, pair->positive.n_ungrouped);
+ long double pos = 1234567.89L;
+ test_one ("%i", positive, "%Li", pos, pair->positive.i);
+ test_one ("%n", positive, "%Ln", pos, pair->positive.n);
+ test_one ("%^i", positive, "%^Li", pos, pair->positive.i_ungrouped);
+ test_one ("%^n", positive, "%^Ln", pos, pair->positive.n_ungrouped);
double negative = -1234567.89;
- test_one ("%i", negative, pair->negative.i);
- test_one ("%n", negative, pair->negative.n);
- test_one ("%^i", negative, pair->negative.i_ungrouped);
- test_one ("%^n", negative, pair->negative.n_ungrouped);
+ long double neg = -1234567.89L;
+ test_one ("%i", negative, "%Li", neg, pair->negative.i);
+ test_one ("%n", negative, "%Ln", neg, pair->negative.n);
+ test_one ("%^i", negative, "%^Li", neg, pair->negative.i_ungrouped);
+ test_one ("%^n", negative, "%^Ln", neg, pair->negative.n_ungrouped);
}
static const struct testcase_pair en_us =
--
2.16.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Add long double input for strfmon test
2018-06-29 10:05 [PATCH] Add long double input for strfmon test Rajalakshmi Srinivasaraghavan
@ 2018-06-29 10:25 ` Florian Weimer
0 siblings, 0 replies; 2+ messages in thread
From: Florian Weimer @ 2018-06-29 10:25 UTC (permalink / raw)
To: Rajalakshmi Srinivasaraghavan, libc-alpha
On 06/29/2018 12:05 PM, Rajalakshmi Srinivasaraghavan wrote:
> 2018-06-29 Rajalakshmi Srinivasaraghavan<raji@linux.vnet.ibm.com>
>
> * stdlib/tst-strfmon_l.c: Add tests for long double.
Looks useful to me. Please commit.
Thanks,
Florian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-29 10:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-29 10:05 [PATCH] Add long double input for strfmon test Rajalakshmi Srinivasaraghavan
2018-06-29 10:25 ` Florian Weimer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).