From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 73673 invoked by alias); 20 Oct 2016 16:56:19 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 73653 invoked by uid 89); 20 Oct 2016 16:56:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.5 required=5.0 tests=AWL,BAYES_50,RCVD_IN_DNSWL_NONE,SPF_PASS,URIBL_RED autolearn=ham version=3.3.2 spammy=10.0, 7th, gomes, Gomes X-HELO: relay1.mentorg.com Date: Thu, 20 Oct 2016 16:56:00 -0000 From: Joseph Myers To: "Gabriel F. T. Gomes" CC: Subject: Re: [PATCH v9 3/3] Add tests for strfrom functions In-Reply-To: <1476803310-2259-1-git-send-email-gftg@linux.vnet.ibm.com> Message-ID: References: <1476803310-2259-1-git-send-email-gftg@linux.vnet.ibm.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-SW-Source: 2016-10/txt/msg00341.txt.bz2 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