summaryrefslogtreecommitdiff
path: root/tests/tadd1sp.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2018-02-16 07:53:26 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2018-02-16 07:53:26 +0000
commit81cc3a3273a3a21fded5c47e90acbb029ff08063 (patch)
treede82f023bec93793a664be1e19a3d2ee0f3597c2 /tests/tadd1sp.c
parent69354ecc455a9735149c2543201fb77c77a86047 (diff)
downloadmpfr-81cc3a3273a3a21fded5c47e90acbb029ff08063.tar.gz
[tests/tadd1sp.c] added coverage test
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@12259 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tadd1sp.c')
-rw-r--r--tests/tadd1sp.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/tadd1sp.c b/tests/tadd1sp.c
index 4c2862ae8..1f45cf23c 100644
--- a/tests/tadd1sp.c
+++ b/tests/tadd1sp.c
@@ -72,6 +72,39 @@ bug20171217 (void)
mpfr_clear (c);
}
+/* Check corner case b = 1, c = 2^(-p) for MPFR_PREC_MIN <= p <= pmax.
+ With RNDN, result is 1, except for p=1, where it is 2. */
+static void
+test_corner_1 (mpfr_prec_t pmax)
+{
+ mpfr_prec_t p;
+
+ for (p = MPFR_PREC_MIN; p <= pmax; p++)
+ {
+ mpfr_t a, b, c;
+ int inex;
+ mpfr_init2 (a, p);
+ mpfr_init2 (b, p);
+ mpfr_init2 (c, p);
+ mpfr_set_ui (b, 1, MPFR_RNDN);
+ mpfr_set_ui_2exp (c, 1, -p, MPFR_RNDN);
+ inex = mpfr_add (a, b, c, MPFR_RNDN);
+ if (p == 1) /* special case, since 2^(p-1) is odd */
+ {
+ MPFR_ASSERTN(inex > 0);
+ MPFR_ASSERTN(mpfr_cmp_ui (a, 2) == 0);
+ }
+ else
+ {
+ MPFR_ASSERTN(inex < 0);
+ MPFR_ASSERTN(mpfr_cmp_ui (a, 1) == 0);
+ }
+ mpfr_clear (a);
+ mpfr_clear (b);
+ mpfr_clear (c);
+ }
+}
+
int
main (void)
{
@@ -79,6 +112,7 @@ main (void)
tests_start_mpfr ();
+ test_corner_1 (1024);
bug20171217 ();
check_special ();
for(p = MPFR_PREC_MIN; p < 200 ; p++)