This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2 3/3] Add tests for strfrom functions
- From: Joseph Myers <joseph at codesourcery dot com>
- To: "Gabriel F. T. Gomes" <gftg at linux dot vnet dot ibm dot com>
- Cc: <libc-alpha at sourceware dot org>
- Date: Fri, 16 Sep 2016 23:27:43 +0000
- Subject: Re: [PATCH v2 3/3] Add tests for strfrom functions
- Authentication-results: sourceware.org; auth=none
- References: <1472569664-12402-1-git-send-email-gftg@linux.vnet.ibm.com> <1472569664-12402-4-git-send-email-gftg@linux.vnet.ibm.com>
On Tue, 30 Aug 2016, Gabriel F. T. Gomes wrote:
> +static const struct ltest ltests[] = {
> + {"12345.3", 12345.345, "%g", 50, 7},
> + {"1.000001", 0x80000Ap-23, "%f", 50, 8},
I'm not sure where this set of test inputs comes from. But I'd expect you
to have test values of the relevant type, not double.
> + rc = FTOSTR (buf, lt->size, lt->fmt, lt->val); \
> + if (strcmp (lt->fmt, "%a") == 0 || strcmp (lt->fmt, "%A") == 0) \
> + rc1 = (strtold (lt->expect, NULL) == strtold (buf, NULL)) \
> + ? 0 : 1; \
And I'm not convinced by the use of strtold here. There are limited
number of possible valid hex strings for given floating-point input; you
could just make the tests list them all.
I don't see test coverage of the results when the buffer is too small.
Or of LC_NUMERIC changes (meaning different decimal points, if it does
have that effect).
--
Joseph S. Myers
joseph@codesourcery.com