add the test for mpf_cmp_z
This commit is contained in:
parent
bc95a1dda2
commit
9df1c781f9
@ -48,6 +48,14 @@ check_data (void)
|
|||||||
{ 10, "-1", "0", -1 },
|
{ 10, "-1", "0", -1 },
|
||||||
{ 10, "-1", "-1", 0 },
|
{ 10, "-1", "-1", 0 },
|
||||||
|
|
||||||
|
{ 10, "1.5", "2", -1 },
|
||||||
|
{ 10, "1.5", "1", 1 },
|
||||||
|
{ 10, "0.5", "1", -1 },
|
||||||
|
|
||||||
|
{ 10, "-1.5", "-2", 1 },
|
||||||
|
{ 10, "-1.5", "-1", -1 },
|
||||||
|
{ 10, "-0.5", "-1", 1 },
|
||||||
|
|
||||||
{ 16, "0", "-0x80000000", 1 },
|
{ 16, "0", "-0x80000000", 1 },
|
||||||
{ 16, "80000000", "-0x80000000", 1 },
|
{ 16, "80000000", "-0x80000000", 1 },
|
||||||
{ 16, "80000001", "-0x80000000", 1 },
|
{ 16, "80000001", "-0x80000000", 1 },
|
||||||
@ -59,8 +67,15 @@ check_data (void)
|
|||||||
{ 16, "8000000000000000", "-0x8000000000000000", 1 },
|
{ 16, "8000000000000000", "-0x8000000000000000", 1 },
|
||||||
{ 16, "8000000000000001", "-0x8000000000000000", 1 },
|
{ 16, "8000000000000001", "-0x8000000000000000", 1 },
|
||||||
{ 16, "-8000000000000000", "-0x8000000000000000", 0 },
|
{ 16, "-8000000000000000", "-0x8000000000000000", 0 },
|
||||||
{ 16, "-8000000000000001", "-0x8000000000000000", -1 },
|
{ 16, "-8000000000000000.1", "-0x8000000000000000", -1 },
|
||||||
{ 16, "-FF008000000000000001", "-0x8000000000000000", -1 },
|
{ 16, "-FF008000000000000001", "-0x8000000000000000", -1 },
|
||||||
|
|
||||||
|
{ 16, "0", "-0x876543210FEDCBA9876543210000000", 1 },
|
||||||
|
{ 16, "876543210FEDCBA9876543210000000", "-0x876543210FEDCBA9876543210000000", 1 },
|
||||||
|
{ 16, "876543210FEDCBA9876543210000001", "-0x876543210FEDCBA9876543210000000", 1 },
|
||||||
|
{ 16, "-876543210FEDCBA9876543210000000", "-0x876543210FEDCBA9876543210000000", 0 },
|
||||||
|
{ 16, "-876543210FEDCBA9876543210000000.1", "-0x876543210FEDCBA9876543210000000", -1 },
|
||||||
|
{ 16, "-FF00876543210FEDCBA9876543210000000", "-0x876543210FEDCBA9876543210000000", -1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
mpf_t a;
|
mpf_t a;
|
||||||
@ -69,7 +84,7 @@ check_data (void)
|
|||||||
int got;
|
int got;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
mpf_init (a);
|
mpf_init2 (a, 128);
|
||||||
mpz_init (bz);
|
mpz_init (bz);
|
||||||
for (i = 0; i < numberof (data); i++)
|
for (i = 0; i < numberof (data); i++)
|
||||||
{
|
{
|
||||||
@ -91,6 +106,19 @@ check_data (void)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
got = mpf_cmp_z (a, bz);
|
||||||
|
if (SGN (got) != data[i].want)
|
||||||
|
{
|
||||||
|
b = mpz_get_si (bz);
|
||||||
|
printf ("mpf_cmp_z wrong on data[%d]\n", i);
|
||||||
|
printf (" a="); mpf_out_str (stdout, 10, 0, a);
|
||||||
|
printf (" (%s)\n", data[i].a);
|
||||||
|
printf (" b=%ld (%s)\n", b, data[i].b);
|
||||||
|
printf (" got=%d\n", got);
|
||||||
|
printf (" want=%d\n", data[i].want);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mpf_clear (a);
|
mpf_clear (a);
|
||||||
|
Loading…
Reference in New Issue
Block a user