diff options
author | Bruno Haible <bruno@clisp.org> | 2007-04-13 16:56:08 +0000 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2007-04-13 16:56:08 +0000 |
commit | d6f2795056e4d0040cdd6c0962518635e174bce4 (patch) | |
tree | b1f55c3cbeed167ede56f58ab3dc93f01b6381c9 /tests/test-printf-posix.h | |
parent | 75032ae61b82138c1d1b9552eec2f96ab1040dc4 (diff) | |
download | gnulib-d6f2795056e4d0040cdd6c0962518635e174bce4.tar.gz |
Add tests for %f and %F directives.
Diffstat (limited to 'tests/test-printf-posix.h')
-rw-r--r-- | tests/test-printf-posix.h | 104 |
1 files changed, 104 insertions, 0 deletions
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 *, ...)) <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ 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); |