From d6f2795056e4d0040cdd6c0962518635e174bce4 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 13 Apr 2007 16:56:08 +0000 Subject: Add tests for %f and %F directives. --- tests/test-printf-posix.h | 104 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) (limited to 'tests/test-printf-posix.h') diff --git a/tests/test-printf-posix.h b/tests/test-printf-posix.h index 5f91480a5d..1b2da47229 100644 --- a/tests/test-printf-posix.h +++ b/tests/test-printf-posix.h @@ -71,6 +71,110 @@ test_function (int (*my_printf) (const char *, ...)) */ my_printf ("%010a %d\n", NaN (), 33, 44, 55); + /* Test the support of the %f format directive. */ + + /* A positive number. */ + my_printf ("%f %d\n", 12.75, 33, 44, 55); + + /* A larger positive number. */ + my_printf ("%f %d\n", 1234567.0, 33, 44, 55); + + /* A negative number. */ + my_printf ("%f %d\n", -0.03125, 33, 44, 55); + + /* Positive zero. */ + my_printf ("%f %d\n", 0.0, 33, 44, 55); + + /* Negative zero. */ + my_printf ("%f %d\n", -0.0, 33, 44, 55); + + /* NaN. */ + my_printf ("%f %d\n", NaN (), 33, 44, 55); + + /* FLAG_ZERO. */ + my_printf ("%015f %d\n", 1234.0, 33, 44, 55); + + /* Precision. */ + my_printf ("%.f %d\n", 1234.0, 33, 44, 55); + + /* A positive number. */ + my_printf ("%Lf %d\n", 12.75L, 33, 44, 55); + + /* A larger positive number. */ + my_printf ("%Lf %d\n", 1234567.0L, 33, 44, 55); + + /* A negative number. */ + my_printf ("%Lf %d\n", -0.03125L, 33, 44, 55); + + /* Positive zero. */ + my_printf ("%Lf %d\n", 0.0L, 33, 44, 55); + + /* Negative zero. */ + my_printf ("%Lf %d\n", -0.0L, 33, 44, 55); + + { /* NaN. */ + static long double zero = 0.0L; + my_printf ("%Lf %d\n", zero / zero, 33, 44, 55); + } + + /* FLAG_ZERO. */ + my_printf ("%015Lf %d\n", 1234.0L, 33, 44, 55); + + /* Precision. */ + my_printf ("%.Lf %d\n", 1234.0L, 33, 44, 55); + + /* Test the support of the %F format directive. */ + + /* A positive number. */ + my_printf ("%F %d\n", 12.75, 33, 44, 55); + + /* A larger positive number. */ + my_printf ("%F %d\n", 1234567.0, 33, 44, 55); + + /* A negative number. */ + my_printf ("%F %d\n", -0.03125, 33, 44, 55); + + /* Positive zero. */ + my_printf ("%F %d\n", 0.0, 33, 44, 55); + + /* Negative zero. */ + my_printf ("%F %d\n", -0.0, 33, 44, 55); + + /* NaN. */ + my_printf ("%F %d\n", NaN (), 33, 44, 55); + + /* FLAG_ZERO. */ + my_printf ("%015F %d\n", 1234.0, 33, 44, 55); + + /* Precision. */ + my_printf ("%.F %d\n", 1234.0, 33, 44, 55); + + /* A positive number. */ + my_printf ("%LF %d\n", 12.75L, 33, 44, 55); + + /* A larger positive number. */ + my_printf ("%LF %d\n", 1234567.0L, 33, 44, 55); + + /* A negative number. */ + my_printf ("%LF %d\n", -0.03125L, 33, 44, 55); + + /* Positive zero. */ + my_printf ("%LF %d\n", 0.0L, 33, 44, 55); + + /* Negative zero. */ + my_printf ("%LF %d\n", -0.0L, 33, 44, 55); + + { /* NaN. */ + static long double zero = 0.0L; + my_printf ("%LF %d\n", zero / zero, 33, 44, 55); + } + + /* FLAG_ZERO. */ + my_printf ("%015LF %d\n", 1234.0L, 33, 44, 55); + + /* Precision. */ + my_printf ("%.LF %d\n", 1234.0L, 33, 44, 55); + /* Test the support of the POSIX/XSI format strings with positions. */ my_printf ("%2$d %1$d\n", 33, 55); -- cgit v1.2.1