]> Savannah Git Hosting - gnulib.git/commitdiff
strtof, strtod, strtold tests: Strengthen tests.
authorBruno Haible <bruno@clisp.org>
Tue, 23 Jul 2024 10:41:12 +0000 (12:41 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jul 2024 10:41:12 +0000 (12:41 +0200)
* tests/test-strtof.h (test_function): Add another overflow test.
* tests/test-strtod.h (test_function): Likewise.
* tests/test-strtold.h (test_function): Likewise.

ChangeLog
tests/test-strtod.h
tests/test-strtof.h
tests/test-strtold.h

index b4d5b8f9f8377991614ddece940b430417d4d24e..309f1d8ac0435ba46e1c6b6a71634f2345a6c72a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-07-23  Bruno Haible  <bruno@clisp.org>
+
+       strtof, strtod, strtold tests: Strengthen tests.
+       * tests/test-strtof.h (test_function): Add another overflow test.
+       * tests/test-strtod.h (test_function): Likewise.
+       * tests/test-strtold.h (test_function): Likewise.
+
 2024-07-23  Bruno Haible  <bruno@clisp.org>
 
        strtold: Revisit underflow behaviour.
index c806953e844ea8a97d7a9d68454700c4511dabdf..211d9230c74636ab8dd26274f69542ab1a96d41f 100644 (file)
@@ -482,6 +482,16 @@ test_function (double (*my_strtod) (const char *, char **))
   }
 
   /* Overflow.  */
+  {
+    const char input[] = "1e500";
+    char *ptr;
+    double result;
+    errno = 0;
+    result = my_strtod (input, &ptr);
+    ASSERT (result == HUGE_VAL);
+    ASSERT (ptr == input + 5);          /* OSF/1 5.1 */
+    ASSERT (errno == ERANGE);
+  }
   {
     const char input[] = "1E1000000";
     char *ptr;
index 2ac6b898dab1b5867be543df7de74887db3e2b64..fd04f07873e9a8d41e64449befaa4c10cb589607 100644 (file)
@@ -482,6 +482,16 @@ test_function (float (*my_strtof) (const char *, char **))
   }
 
   /* Overflow.  */
+  {
+    const char input[] = "1e50";
+    char *ptr;
+    float result;
+    errno = 0;
+    result = my_strtof (input, &ptr);
+    ASSERT (result == HUGE_VAL);
+    ASSERT (ptr == input + 4);          /* OSF/1 5.1 */
+    ASSERT (errno == ERANGE);
+  }
   {
     const char input[] = "1E1000000";
     char *ptr;
index bd12988c4cdf75c4b23eed72b04bc9397ec995d3..a872f8a882420aa47a1738f9e895186d49877780 100644 (file)
@@ -482,6 +482,16 @@ test_function (long double (*my_strtold) (const char *, char **))
   }
 
   /* Overflow.  */
+  {
+    const char input[] = "1e6000";
+    char *ptr;
+    long double result;
+    errno = 0;
+    result = my_strtold (input, &ptr);
+    ASSERT (result == HUGE_VALL);
+    ASSERT (ptr == input + 6);
+    ASSERT (errno == ERANGE);
+  }
   {
     const char input[] = "1E1000000";
     char *ptr;