]> sourceware.org Git - glibc.git/commitdiff
Add tests of more strtod special cases
authorJoseph Myers <josmyers@redhat.com>
Fri, 20 Sep 2024 23:24:45 +0000 (23:24 +0000)
committerJoseph Myers <josmyers@redhat.com>
Fri, 20 Sep 2024 23:24:45 +0000 (23:24 +0000)
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.

stdlib/tst-strtod2.c

index c84bd792c1a3f511ada836d660b34a6585bcd13c..d00bc13323c50622935cc7dbc2260f8578d47e96 100644 (file)
@@ -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 },                                         \
This page took 0.03925 seconds and 5 git commands to generate.