Rewrite the zero shortcut tests to avoid dropping a const qualifier.

This commit is contained in:
Dag-Erling Smørgrav 2014-12-30 20:03:58 +00:00 committed by des
parent 3904e809b2
commit cddb6c0e02

View file

@ -1516,14 +1516,14 @@ t_mpi_sub_a_from_a(char **desc CRYB_UNUSED, void *arg CRYB_UNUSED)
* Target is the first operand, second operand is zero * Target is the first operand, second operand is zero
*/ */
static int static int
t_mpi_sub_z_from_a(char **desc CRYB_UNUSED, void *arg CRYB_UNUSED) t_mpi_sub_zero_from_a(char **desc CRYB_UNUSED, void *arg CRYB_UNUSED)
{ {
cryb_mpi a = CRYB_MPI_ZERO, e = CRYB_MPI_ZERO; cryb_mpi a = CRYB_MPI_ZERO, b = CRYB_MPI_ZERO, e = CRYB_MPI_ZERO;
int ret = 1; int ret = 1;
mpi_set(&a, 0x20140901); mpi_set(&a, 0x20140901);
mpi_set(&e, 0x20140901); mpi_set(&e, 0x20140901);
ret &= t_compare_i(0, mpi_sub_abs(&a, &a, &z)); ret &= t_compare_i(0, mpi_sub_abs(&a, &a, &b));
ret &= t_compare_mpi(&e, &a); ret &= t_compare_mpi(&e, &a);
mpi_destroy(&a); mpi_destroy(&a);
mpi_destroy(&e); mpi_destroy(&e);
@ -1534,14 +1534,14 @@ t_mpi_sub_z_from_a(char **desc CRYB_UNUSED, void *arg CRYB_UNUSED)
* Target is the second operand, first operand is zero * Target is the second operand, first operand is zero
*/ */
static int static int
t_mpi_sub_b_from_z(char **desc CRYB_UNUSED, void *arg CRYB_UNUSED) t_mpi_sub_b_from_zero(char **desc CRYB_UNUSED, void *arg CRYB_UNUSED)
{ {
cryb_mpi b = CRYB_MPI_ZERO, e = CRYB_MPI_ZERO; cryb_mpi a = CRYB_MPI_ZERO, b = CRYB_MPI_ZERO, e = CRYB_MPI_ZERO;
int ret = 1; int ret = 1;
mpi_set(&b, 0x20140901); mpi_set(&b, 0x20140901);
mpi_set(&e, 0x20140901); mpi_set(&e, 0x20140901);
ret &= t_compare_i(0, mpi_sub_abs(&b, &z, &b)); ret &= t_compare_i(0, mpi_sub_abs(&b, &a, &b));
ret &= t_compare_mpi(&e, &b); ret &= t_compare_mpi(&e, &b);
mpi_destroy(&b); mpi_destroy(&b);
mpi_destroy(&e); mpi_destroy(&e);
@ -1644,8 +1644,8 @@ t_prepare(int argc, char *argv[])
t_add_test(t_mpi_sub_a_from_b, NULL, "b = a - b"); t_add_test(t_mpi_sub_a_from_b, NULL, "b = a - b");
t_add_test(t_mpi_sub_a_from_b_fail, NULL, "b = a - b (failure)"); t_add_test(t_mpi_sub_a_from_b_fail, NULL, "b = a - b (failure)");
t_add_test(t_mpi_sub_a_from_a, NULL, "a = a - a"); t_add_test(t_mpi_sub_a_from_a, NULL, "a = a - a");
t_add_test(t_mpi_sub_b_from_z, NULL, "b = 0 - b"); t_add_test(t_mpi_sub_b_from_zero, NULL, "b = 0 - b");
t_add_test(t_mpi_sub_z_from_a, NULL, "a = a - z"); t_add_test(t_mpi_sub_zero_from_a, NULL, "a = a - z");
return (0); return (0);
} }