diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-07-06 11:49:12 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-07-06 11:49:12 +0000 |
commit | 55487c8baa9a72d7e55d0bcb89387dd2b7f192cc (patch) | |
tree | f49b9c0453cfb718039b0f1c383d63801882e48c /tests/tprintf.c | |
parent | c97cc62c89ee9fe19f900bde7dcbca9ff464de98 (diff) | |
download | mpfr-55487c8baa9a72d7e55d0bcb89387dd2b7f192cc.tar.gz |
[tests/{tprintf.c,tsprintf.c}] Added tests with powers of ten in all
rounding modes and powers of ten + 0.5 in rounding to nearest.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@12893 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tprintf.c')
-rw-r--r-- | tests/tprintf.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/tests/tprintf.c b/tests/tprintf.c index 20132e41a..44a31da7c 100644 --- a/tests/tprintf.c +++ b/tests/tprintf.c @@ -533,10 +533,30 @@ test_locale (void) check_length (10002 + i, count, 12 + i + i/3, d); } - /* TODO: add tests with powers of ten in all rounding modes - and powers of ten + 0.5 in rounding to nearest. Then add - the corresponding tests to tsprintf.c too. This may give - information for the FIXME in "src/vasprintf.c". */ +#define N0 20 + + for (i = 1; i <= N0; i++) + { + char s[N0+4]; + int j, rnd; + + s[0] = '1'; + for (j = 1; j <= i; j++) + s[j] = '0'; + s[i+1] = '\0'; + + mpfr_set_str (x, s, 10, MPFR_RNDN); + + RND_LOOP (rnd) + { + count = mpfr_printf ("(5) 10^i=%'.0R*f \n", (mpfr_rnd_t) rnd, x); + check_length (11000 + 10 * i + rnd, count, 12 + i + i/3, d); + } + + strcat (s + (i + 1), ".5"); + count = mpfr_printf ("(5) 10^i=%'.0Rf \n", x); + check_length (11000 + 10 * i + 9, count, 12 + i + i/3, d); + } mpfr_clear (x); } |