From: Bruno Haible <bruno@clisp.org>
Date: Thu, 12 Dec 2019 23:19:56 +0000 (+0100)
Subject: strtod, strtold tests: Avoid test failure on AIX 7.2.
X-Git-Tag: v1.0~4511
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=1fabf601fa87579a9eaed42c92c6bb9a97922c1d;p=gnulib.git

strtod, strtold tests: Avoid test failure on AIX 7.2.

* tests/test-strtod1.c (main): Allow implementations in which ',' and
'.' both are radix characters.
* tests/test-strtold1.c (main): Likewise.
---

diff --git a/ChangeLog b/ChangeLog
index aa25cfde09..b0c7543e53 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2019-12-12  Bruno Haible  <bruno@clisp.org>
+
+	strtod, strtold tests: Avoid test failure on AIX 7.2.
+	* tests/test-strtod1.c (main): Allow implementations in which ',' and
+	'.' both are radix characters.
+	* tests/test-strtold1.c (main): Likewise.
+
 2019-12-12  Paul Eggert  <eggert@cs.ucla.edu>
 
 	dfa: prefer ptrdiff_t for API, too
diff --git a/tests/test-strtod1.c b/tests/test-strtod1.c
index 75200ccfea..26b96beaa0 100644
--- a/tests/test-strtod1.c
+++ b/tests/test-strtod1.c
@@ -68,8 +68,10 @@ main (int argc, char *argv[])
     double result;
     errno = 0;
     result = strtod (input, &ptr);
-    ASSERT (result == 1.0);
-    ASSERT (ptr == input + 1);
+    /* On AIX 7.2, in the French locale, '.' is recognized as an alternate
+       radix character.  */
+    ASSERT ((ptr == input + 1 && result == 1.0)
+            || (ptr == input + 3 && result == 1.5));
     ASSERT (errno == 0);
   }
   {
@@ -78,8 +80,10 @@ main (int argc, char *argv[])
     double result;
     errno = 0;
     result = strtod (input, &ptr);
-    ASSERT (result == 123.0);
-    ASSERT (ptr == input + 3);
+    /* On AIX 7.2, in the French locale, '.' is recognized as an alternate
+       radix character.  */
+    ASSERT ((ptr == input + 3 && result == 123.0)
+            || (ptr == input + 7 && result > 123.45 && result < 123.46));
     ASSERT (errno == 0);
   }
   {
diff --git a/tests/test-strtold1.c b/tests/test-strtold1.c
index 3a2f533b35..e58174b062 100644
--- a/tests/test-strtold1.c
+++ b/tests/test-strtold1.c
@@ -68,8 +68,10 @@ main (int argc, char *argv[])
     long double result;
     errno = 0;
     result = strtold (input, &ptr);
-    ASSERT (result == 1.0L);
-    ASSERT (ptr == input + 1);
+    /* On AIX 7.2, in the French locale, '.' is recognized as an alternate
+       radix character.  */
+    ASSERT ((ptr == input + 1 && result == 1.0L)
+            || (ptr == input + 3 && result == 1.5L));
     ASSERT (errno == 0);
   }
   {
@@ -78,8 +80,10 @@ main (int argc, char *argv[])
     long double result;
     errno = 0;
     result = strtold (input, &ptr);
-    ASSERT (result == 123.0L);
-    ASSERT (ptr == input + 3);
+    /* On AIX 7.2, in the French locale, '.' is recognized as an alternate
+       radix character.  */
+    ASSERT ((ptr == input + 3 && result == 123.0L)
+            || (ptr == input + 7 && result > 123.45L && result < 123.46L));
     ASSERT (errno == 0);
   }
   {