summary refs log tree commit diff
path: root/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
diff options
context:
space:
mode:
authorGabriel F. T. Gomes <gabrielftg@linux.ibm.com>2019-07-11 11:47:06 -0300
committerGabriel F. T. Gomes <gabrielftg@linux.ibm.com>2019-11-22 18:12:37 -0300
commit5bbbd5ae057c8f862e65d9a230bccb2364f48f96 (patch)
treed11c663185dc3c8eac33ca7ac74eaf6a8aa66f9c /sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
parent329037cead5f7930c6081d130b22e03b0ff5e3a8 (diff)
downloadglibc-5bbbd5ae057c8f862e65d9a230bccb2364f48f96.tar.gz
glibc-5bbbd5ae057c8f862e65d9a230bccb2364f48f96.tar.xz
glibc-5bbbd5ae057c8f862e65d9a230bccb2364f48f96.zip
ldbl-128ibm-compat: Test double values
A single format string can take double and long double parameters at the
same time.  Internally, these parameters are routed to the same
function, which correctly reads them and calls the underlying functions
responsible for the actual conversion to string.  This patch adds a new
case to test this scenario.

Tested for powerpc64le.

Reviewed-By: Paul E. Murphy <murphyp@linux.ibm.com>
Diffstat (limited to 'sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c')
-rw-r--r--sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c71
1 files changed, 36 insertions, 35 deletions
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
index 939a6aad9c..2b8d424473 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
@@ -78,13 +78,13 @@ do_test_call_varg (FILE *stream, const char *format, ...)
 }
 
 static void
-do_test_call_rarg (FILE *stream, const char *format, long double ld)
+do_test_call_rarg (FILE *stream, const char *format, long double ld, double d)
 {
   char *buffer = NULL;
   char string[128];
 
   printf ("%15s", "asprintf: ");
-  asprintf (&buffer, format, ld);
+  asprintf (&buffer, format, ld, d);
   if (buffer == NULL)
     printf ("Error using asprintf\n");
   else
@@ -95,24 +95,24 @@ do_test_call_rarg (FILE *stream, const char *format, long double ld)
   printf ("\n");
 
   printf ("%15s", "dprintf: ");
-  dprintf (fileno (stream), format, ld);
+  dprintf (fileno (stream), format, ld, d);
   printf ("\n");
 
   printf ("%15s", "fprintf: ");
-  fprintf (stream, format, ld);
+  fprintf (stream, format, ld, d);
   printf ("\n");
 
   printf ("%15s", "printf: ");
-  printf (format, ld);
+  printf (format, ld, d);
   printf ("\n");
 
   printf ("%15s", "snprintf: ");
-  snprintf (string, 127, format, ld);
+  snprintf (string, 127, format, ld, d);
   printf ("%s", string);
   printf ("\n");
 
   printf ("%15s", "sprintf: ");
-  sprintf (string, format, ld);
+  sprintf (string, format, ld, d);
   printf ("%s", string);
   printf ("\n");
 }
@@ -121,14 +121,15 @@ static void
 do_test_call (void)
 {
   long double ld = -1;
+  double d = -1;
 
   /* Print in decimal notation.  */
-  do_test_call_rarg (stdout, "%.10Lf", ld);
-  do_test_call_varg (stdout, "%.10Lf", ld);
+  do_test_call_rarg (stdout, "%.10Lf, %.10f", ld, d);
+  do_test_call_varg (stdout, "%.10Lf, %.10f", ld, d);
 
   /* Print in hexadecimal notation.  */
-  do_test_call_rarg (stdout, "%.10La", ld);
-  do_test_call_varg (stdout, "%.10La", ld);
+  do_test_call_rarg (stdout, "%.10La, %.10a", ld, d);
+  do_test_call_varg (stdout, "%.10La, %.10a", ld, d);
 }
 
 static int
@@ -139,30 +140,30 @@ do_test (void)
 
   /* Compare against the expected output.  */
   const char *expected =
-    "     asprintf: -1.0000000000\n"
-    "      dprintf: -1.0000000000\n"
-    "      fprintf: -1.0000000000\n"
-    "       printf: -1.0000000000\n"
-    "     snprintf: -1.0000000000\n"
-    "      sprintf: -1.0000000000\n"
-    "    vasprintf: -1.0000000000\n"
-    "     vdprintf: -1.0000000000\n"
-    "     vfprintf: -1.0000000000\n"
-    "      vprintf: -1.0000000000\n"
-    "    vsnprintf: -1.0000000000\n"
-    "     vsprintf: -1.0000000000\n"
-    "     asprintf: -0x1.0000000000p+0\n"
-    "      dprintf: -0x1.0000000000p+0\n"
-    "      fprintf: -0x1.0000000000p+0\n"
-    "       printf: -0x1.0000000000p+0\n"
-    "     snprintf: -0x1.0000000000p+0\n"
-    "      sprintf: -0x1.0000000000p+0\n"
-    "    vasprintf: -0x1.0000000000p+0\n"
-    "     vdprintf: -0x1.0000000000p+0\n"
-    "     vfprintf: -0x1.0000000000p+0\n"
-    "      vprintf: -0x1.0000000000p+0\n"
-    "    vsnprintf: -0x1.0000000000p+0\n"
-    "     vsprintf: -0x1.0000000000p+0\n";
+    "     asprintf: -1.0000000000, -1.0000000000\n"
+    "      dprintf: -1.0000000000, -1.0000000000\n"
+    "      fprintf: -1.0000000000, -1.0000000000\n"
+    "       printf: -1.0000000000, -1.0000000000\n"
+    "     snprintf: -1.0000000000, -1.0000000000\n"
+    "      sprintf: -1.0000000000, -1.0000000000\n"
+    "    vasprintf: -1.0000000000, -1.0000000000\n"
+    "     vdprintf: -1.0000000000, -1.0000000000\n"
+    "     vfprintf: -1.0000000000, -1.0000000000\n"
+    "      vprintf: -1.0000000000, -1.0000000000\n"
+    "    vsnprintf: -1.0000000000, -1.0000000000\n"
+    "     vsprintf: -1.0000000000, -1.0000000000\n"
+    "     asprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "      dprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "      fprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "       printf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     snprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "      sprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    vasprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     vdprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     vfprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "      vprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    vsnprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     vsprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n";
   TEST_COMPARE_STRING (expected, result.out.buffer);
 
   return 0;