public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Joseph Myers <joseph@codesourcery.com>
To: "Gabriel F. T. Gomes" <gftg@linux.vnet.ibm.com>
Cc: <libc-alpha@sourceware.org>
Subject: Re: [PATCH v9 3/3] Add tests for strfrom functions
Date: Thu, 20 Oct 2016 16:56:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.20.1610201644180.15386@digraph.polyomino.org.uk> (raw)
In-Reply-To: <1476803310-2259-1-git-send-email-gftg@linux.vnet.ibm.com>

On Tue, 18 Oct 2016, Gabriel F. T. Gomes wrote:

> +/* Hexadecimal tests.  */
> +static const struct htests htest[] = {
> +  {"%a", { "0x1,ffp+6", "0x3,fep+5", "0x7,fcp+4", "0xf,f8p+3" },
> +   {0x1.ffp+6, 0x1.ffp+6, 0x1.ffp+6}},
> +  {"%a", { "0x1,88p+4", "0x3,1p+3", "0x6,2p+2", "0xc,4p+1" },
> +   {0x1.88p+4, 0x1.88p+4, 0x1.88p+4}},
> +  {"%A", { "-0X1,88P+5", "-0X3,1P+4", "-0X6,2P+3", "-0XC,4P+2" },
> +   {-0x1.88p+5, -0x1.88p+5, -0x1.88p+5}},
> +  {"%a", { "0x1,44p+10", "0x2,88p+9", "0x5,1p+8", "0xa,2p+7"},
> +   {0x1.44p+10, 0x1.44p+10, 0x1.44p+10}},
> +  {"%a", { "0x1p-10", "0x2p-11", "0x4p-12", "0x8p-13"},
> +   {0x0.0040p+0, 0x0.0040p+0, 0x0.0040p+0}},
> +  {"%a", { "0x1,4p+3", "0x2,8p+2", "0x5p+1", "0xap+0"},
> +   {10.0, 10.0, 10.0}}
> +};

These still aren't type-generic.

> +/* Hexadecimal tests.  */
> +static const struct htests htest[] = {
> +  {"%a", { "0x1.ffp+6", "0x3.fep+5", "0x7.fcp+4", "0xf.f8p+3" },
> +   {0x1.ffp+6, 0x1.ffp+6, 0x1.ffp+6}},
> +  {"%a", { "0x1.88p+4", "0x3.1p+3", "0x6.2p+2", "0xc.4p+1" },
> +   {0x1.88p+4, 0x1.88p+4, 0x1.88p+4}},
> +  {"%A", { "-0X1.88P+5", "-0X3.1P+4", "-0X6.2P+3", "-0XC.4P+2" },
> +   {-0x1.88p+5, -0x1.88p+5, -0x1.88p+5}},
> +  {"%a", { "0x1.44p+10", "0x2.88p+9", "0x5.1p+8", "0xa.2p+7"},
> +   {0x1.44p+10, 0x1.44p+10, 0x1.44p+10}},
> +  {"%a", { "0x1p-10", "0x2p-11", "0x4p-12", "0x8p-13"},
> +   {0x0.0040p+0, 0x0.0040p+0, 0x0.0040p+0}},
> +  {"%a", { "0x1.4p+3", "0x2.8p+2", "0x5p+1", "0xap+0"},
> +   {10.0, 10.0, 10.0}}

Likewise.

> +#define TEST(s, fmt, size, rc, f, d, ld)	\
> +  {						\
> +    s, fmt, size, rc,  { ENTRY (f, d, ld) }	\
> +  }

You should have one argument to TEST that is the constant used for all 
types (and that then gets the appropriate suffix added to it for each 
type).  It should not be necessary to update the tables of tests at all 
when adding a new floating-point type (in general, the idea of making such 
tests type-generic is so that as little as possible needs to change to 
make them test a new type; ideally only the definitions of 
GEN_TEST_STRTOD_FOREACH and STRTOD_TEST_FOREACH).  The only obvious 
differences I see between the constants in your tests for different types 
is that some have more precision in the constants for double and long 
double, but it's fine to have the extra digits in the float constant even 
if they aren't significant to its value.

That is, the definition should look something like

{ s, fmt, size, rc, { GEN_TEST_STRTOD_FOREACH (SOMETHING, f) } }

where SOMETHING expands to concatenate its 7th argument (the 
floating-point number) with its 5th (the constant suffix) (followed by a 
comma).  Then I think you can get rid of the ENTRY and CHOOSE macros.

(tst-strtod-round is different because it involves data for every 
floating-point *format*, which then needs mapping to the supported types.)

-- 
Joseph S. Myers
joseph@codesourcery.com

  reply	other threads:[~2016-10-20 16:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-14 17:31 [PATCH v8 0/3] New " Gabriel F. T. Gomes
2016-10-14 17:31 ` [PATCH v8 1/3] Add strfromd, strfromf, and strfroml functions Gabriel F. T. Gomes
2016-10-14 17:31 ` [PATCH v8 3/3] Add tests for strfrom functions Gabriel F. T. Gomes
2016-10-14 18:50   ` Gabriel F. T. Gomes
2016-10-14 21:40   ` Joseph Myers
2016-10-18 15:08     ` [PATCH v9 " Gabriel F. T. Gomes
2016-10-20 16:56       ` Joseph Myers [this message]
2016-10-24 14:57         ` [PATCH v10 " Gabriel F. T. Gomes
2016-10-25 16:18           ` Joseph Myers
2016-10-26  0:27             ` Gabriel F. T. Gomes
2016-10-14 17:31 ` [PATCH v8 2/3] Refactor strtod tests Gabriel F. T. Gomes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1610201644180.15386@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=gftg@linux.vnet.ibm.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).