diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2010-03-11 09:24:00 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2010-03-11 09:24:00 +0000 |
commit | 7b56a05db58551638cc5bfdb7408cf78c2b2bc36 (patch) | |
tree | f15ad3d5a1dc90ea1509fa6ef1885d2c02b2f676 /tests | |
parent | fe4bd47bfb9b3c7003c4838d5c11fef221d9f2aa (diff) | |
download | mpfr-7b56a05db58551638cc5bfdb7408cf78c2b2bc36.tar.gz |
[tstrtofr.c] added test for 1.23e, cf
http://gmplib.org/list-archives/gmp-bugs/2010-March/001898.html
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@6719 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tstrtofr.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/tstrtofr.c b/tests/tstrtofr.c index 4c8fa533d..e21265126 100644 --- a/tests/tstrtofr.c +++ b/tests/tstrtofr.c @@ -1078,6 +1078,33 @@ bug20081028 (void) mpfr_clear (x); } +/* check that 1.23e is correctly parsed, cf + http://gmplib.org/list-archives/gmp-bugs/2010-March/001898.html */ +static void +test20100310 (void) +{ + mpfr_t x, y; + char str[] = "1.23e", *endptr; + + mpfr_init2 (x, 53); + mpfr_init2 (y, 53); + mpfr_strtofr (x, str, &endptr, 10, GMP_RNDN); + mpfr_strtofr (y, "1.23", NULL, 10, GMP_RNDN); + if (mpfr_cmp (x, y) != 0) + { + printf ("x <> y in test20100310\n"); + exit (1); + } + if (endptr != str + 4) /* strtofr should take into account '1.23', + not '1.23e' */ + { + printf ("endptr <> str + 4 in test20100310\n"); + exit (1); + } + mpfr_clear (x); + mpfr_clear (y); +} + int main (int argc, char *argv[]) { @@ -1089,6 +1116,7 @@ main (int argc, char *argv[]) check_overflow (); check_retval (); bug20081028 (); + test20100310 (); tests_end_mpfr (); return 0; |