diff mbox series

Add tests of more strtod special cases

Message ID 445d863a-ce-d69e-4334-86efbd1b38cf@redhat.com
State New
Headers show
Series Add tests of more strtod special cases | expand

Commit Message

Joseph Myers Aug. 19, 2024, 9:35 p.m. UTC
There is very little test coverage of inputs to strtod-family
functions that don't contain anything that can be parsed as a number
(one test of ".y" in tst-strtod2), and none that I can see of skipping
initial whitespace.  Add some tests of these things to tst-strtod2.

Tested for x86_64.

---

This test is relative to a tree with
<https://sourceware.org/pipermail/libc-alpha/2024-August/159183.html>
and
<https://sourceware.org/pipermail/libc-alpha/2024-August/159209.html>
(pending review) applied.

Comments

Joseph Myers Aug. 27, 2024, 8:49 p.m. UTC | #1
Ping.  This patch 
<https://sourceware.org/pipermail/libc-alpha/2024-August/159287.html> is 
pending review.
Joseph Myers Sept. 3, 2024, 5:59 p.m. UTC | #2
Ping^2.  This patch 
<https://sourceware.org/pipermail/libc-alpha/2024-August/159287.html> is 
still pending review.
Andreas Schwab Sept. 4, 2024, 12:07 p.m. UTC | #3
On Aug 19 2024, Joseph Myers wrote:

> There is very little test coverage of inputs to strtod-family
> functions that don't contain anything that can be parsed as a number
> (one test of ".y" in tst-strtod2), and none that I can see of skipping
> initial whitespace.  Add some tests of these things to tst-strtod2.

Ok.
diff mbox series

Patch

diff --git a/stdlib/tst-strtod2.c b/stdlib/tst-strtod2.c
index c84bd792c1..d00bc13323 100644
--- a/stdlib/tst-strtod2.c
+++ b/stdlib/tst-strtod2.c
@@ -31,6 +31,20 @@  struct test_strto ## FSUF						\
   { "0x1px", 1.0 ## LSUF, 3 },						\
   { "0x1p+x", 1.0 ## LSUF, 3 },						\
   { "0x1p-x", 1.0 ## LSUF, 3 },						\
+  { "", 0.0 ## LSUF, 0 },						\
+  { ".", 0.0 ## LSUF, 0 },						\
+  { "-", 0.0 ## LSUF, 0 },						\
+  { "-.", 0.0 ## LSUF, 0 },						\
+  { ".e", 0.0 ## LSUF, 0 },						\
+  { "-.e", 0.0 ## LSUF, 0 },						\
+  { " \t", 0.0 ## LSUF, 0 },						\
+  { " \t.", 0.0 ## LSUF, 0 },						\
+  { " \t-", 0.0 ## LSUF, 0 },						\
+  { " \t-.", 0.0 ## LSUF, 0 },						\
+  { " \t.e", 0.0 ## LSUF, 0 },						\
+  { " \t-.e", 0.0 ## LSUF, 0 },						\
+  { " \t\f\r\n\v1", 1.0 ## LSUF, 7 },					\
+  { " \t\f\r\n\v-1.5e2", -150.0 ## LSUF, 12 },				\
   { "INFx", INFINITY, 3 },						\
   { "infx", INFINITY, 3 },						\
   { "INFINITx", INFINITY, 3 },						\