diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2017-05-22 11:31:16 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2017-05-22 11:31:16 +0000 |
commit | 7450303717c09d5048539e6e49693da46ab56bb0 (patch) | |
tree | a2fde204b50d23a09fea88875c48f3454dfb55bc | |
parent | 437927b883da3138464a7690d473d330583d894c (diff) | |
download | mpfr-7450303717c09d5048539e6e49693da46ab56bb0.tar.gz |
[tests/tsprintf.c] Added percent_n() test to reproduce the bug found
in mixed(), bug without random data.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@11517 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | tests/tsprintf.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/tsprintf.c b/tests/tsprintf.c index 17d5a43fe..ea2b15f5f 100644 --- a/tests/tsprintf.c +++ b/tests/tsprintf.c @@ -1394,6 +1394,33 @@ snprintf_size (void) mpfr_clear (x); } +/* With r11516, n2 gets a random value for i = 0 only!!! */ +static void +percent_n (void) +{ + int err = 0, i, j; + + for (i = 0; i < 24; i++) + for (j = 0; j < 3; j++) + { + volatile int n1, n2; + char buffer[64]; + + memset (buffer, 0, 64); + n2 = -17; + n1 = mpfr_snprintf (buffer, i % 8, "%d%n", 123, &n2); + if (n1 != 3 || n2 != 3) + { + printf ("Error 1 in percent_n: i = %d, n1 = %d, n2 = %d\n", + i, n1, n2); + err = 1; + } + } + + if (err) + exit (1); +} + int main (int argc, char **argv) { @@ -1430,7 +1457,7 @@ main (int argc, char **argv) test20161214 (); bug21056 (); snprintf_size (); - + percent_n (); mixed (); if (getenv ("MPFR_CHECK_LIBC_PRINTF")) |