Commit 7640fd2c authored by Davide Galassi's avatar Davide Galassi

Removed old MPI tests with hardcoded values

parent 5008a964
Pipeline #57391028 passed with stages
in 1 minute and 38 seconds
#include "mpi_test.h"
static void mpi_add_no_expand(void)
{
ASSERT_OK(cry_mpi_load_bin(g_mpi0, g_a6400_bin, 1));
ASSERT_OK(cry_mpi_load_bin(g_mpi1, g_b6400_bin, 1));
ASSERT_OK(cry_mpi_add(g_mpi2, g_mpi0, g_mpi1));
ASSERT_EQ_MPI(g_mpi2, g_a8_b8_add_bin, sizeof(g_a8_b8_add_bin));
}
static void mpi_add_with_swap(void)
{
ASSERT_OK(cry_mpi_load_bin(g_mpi0, g_a6400_bin, 1));
ASSERT_OK(cry_mpi_load_bin(g_mpi1, g_b6400_bin, 32));
ASSERT_OK(cry_mpi_add(g_mpi2, g_mpi0, g_mpi1));
ASSERT_EQ_MPI(g_mpi2, g_a8_b256_add_bin, sizeof(g_a8_b256_add_bin));
}
static void mpi_add_expand_no_final_carry(void)
{
ASSERT_OK(cry_mpi_load_bin(g_mpi0, g_a6400_bin, 128));
ASSERT_OK(cry_mpi_load_bin(g_mpi1, g_a6400_bin, 64));
ASSERT_OK(cry_mpi_add(g_mpi2, g_mpi0, g_mpi1));
ASSERT_EQ_MPI(g_mpi2, g_a1024_a512_add_bin, sizeof(g_a1024_a512_add_bin));
}
static void mpi_add_expand_final_carry(void)
{
ASSERT_OK(cry_mpi_load_bin(g_mpi0, g_a6400_bin, 128));
ASSERT_OK(cry_mpi_load_bin(g_mpi1, g_a6400_bin, 128));
ASSERT_OK(cry_mpi_add(g_mpi2, g_mpi0, g_mpi1));
ASSERT_EQ_MPI(g_mpi2, g_a1024_a1024_add_bin, sizeof(g_a1024_a1024_add_bin));
}
static void mpi_add_diff_sign_first_neg_and_bigger(void)
{
ASSERT_OK(cry_mpi_load_bin(g_mpi0, g_a6400_bin, 33));
ASSERT_OK(cry_mpi_load_bin(g_mpi1, g_a6400_bin, 32));
g_mpi0->sign = 1;
ASSERT_OK(cry_mpi_add(g_mpi2, g_mpi0, g_mpi1));
ASSERT_EQ(cry_mpi_is_neg(g_mpi2), 1);
ASSERT_EQ_MPI(g_mpi2, g_a264_a256_add_sign_bin,
sizeof(g_a264_a256_add_sign_bin));
}
static void mpi_add_diff_sign_first_pos_and_bigger(void)
{
ASSERT_OK(cry_mpi_load_bin(g_mpi0, g_a6400_bin, 33));
ASSERT_OK(cry_mpi_load_bin(g_mpi1, g_a6400_bin, 32));
g_mpi1->sign = 1;
ASSERT_OK(cry_mpi_add(g_mpi2, g_mpi0, g_mpi1));
ASSERT_EQ(cry_mpi_is_neg(g_mpi2), 0);
ASSERT_EQ_MPI(g_mpi2, g_a264_a256_add_sign_bin,
sizeof(g_a264_a256_add_sign_bin));
}
static void mpi_add_diff_sign_first_neg_and_smaller(void)
{
ASSERT_OK(cry_mpi_load_bin(g_mpi0, g_a6400_bin, 32));
ASSERT_OK(cry_mpi_load_bin(g_mpi1, g_a6400_bin, 33));
g_mpi0->sign = 1;
ASSERT_OK(cry_mpi_add(g_mpi2, g_mpi0, g_mpi1));
ASSERT_EQ(cry_mpi_is_neg(g_mpi2), 0);
ASSERT_EQ_MPI(g_mpi2, g_a264_a256_add_sign_bin,
sizeof(g_a264_a256_add_sign_bin));
}
static void mpi_add_diff_sign_first_pos_and_smaller(void)
{
ASSERT_OK(cry_mpi_load_bin(g_mpi0, g_a6400_bin, 32));
ASSERT_OK(cry_mpi_load_bin(g_mpi1, g_a6400_bin, 33));
g_mpi1->sign = 1;
ASSERT_OK(cry_mpi_add(g_mpi2, g_mpi0, g_mpi1));
ASSERT_EQ(cry_mpi_is_neg(g_mpi2), 1);
ASSERT_EQ_MPI(g_mpi2, g_a264_a256_add_sign_bin,
sizeof(g_a264_a256_add_sign_bin));
}
static void mpi_add_diff_sign_equal_magnitude(void)
{
ASSERT_OK(cry_mpi_load_bin(g_mpi0, g_a6400_bin, 32));
ASSERT_OK(cry_mpi_load_bin(g_mpi1, g_a6400_bin, 32));
g_mpi0->sign = 1;
ASSERT_OK(cry_mpi_add(g_mpi2, g_mpi0, g_mpi1));
ASSERT_EQ(cry_mpi_is_pos(g_mpi2), 1);
ASSERT_EQ(cry_mpi_is_zero(g_mpi2), 1);
}
/* Entry point */
void mpi_add_test(void)
{
MPI_RUN(mpi_add_no_expand);
MPI_RUN(mpi_add_with_swap);
MPI_RUN(mpi_add_expand_no_final_carry);
MPI_RUN(mpi_add_expand_final_carry);
MPI_RUN(mpi_add_diff_sign_first_neg_and_bigger);
MPI_RUN(mpi_add_diff_sign_first_pos_and_bigger);
MPI_RUN(mpi_add_diff_sign_first_neg_and_smaller);
MPI_RUN(mpi_add_diff_sign_first_pos_and_smaller);
MPI_RUN(mpi_add_diff_sign_equal_magnitude);
}
#include "mpi_test.h"
static void equal(void)
{
cry_mpi_load_bin(g_mpi0, g_a6400_bin, 64);
cry_mpi_load_bin(g_mpi1, g_a6400_bin, 64);
ASSERT_EQ(cry_mpi_cmp(g_mpi0, g_mpi1), 0);
}
static void not_equal_same_len(void)
{
cry_mpi_load_bin(g_mpi0, g_a6400_bin, 64);
cry_mpi_load_bin(g_mpi1, g_b6400_bin, 64);
ASSERT_EQ(cry_mpi_cmp(g_mpi0, g_mpi1) > 0, 1);
ASSERT_EQ(cry_mpi_cmp(g_mpi1, g_mpi0) < 0, 1);
}
static void not_equal_same_len_neg(void)
{
cry_mpi_load_bin(g_mpi0, g_a6400_bin, 64);
cry_mpi_load_bin(g_mpi1, g_b6400_bin, 64);
g_mpi0->sign = g_mpi1->sign = 1; /* Negative numbers */
ASSERT_EQ(cry_mpi_cmp(g_mpi0, g_mpi1) < 0, 1);
ASSERT_EQ(cry_mpi_cmp(g_mpi1, g_mpi0) > 0, 1);
}
static void not_equal_diff_len(void)
{
cry_mpi_load_bin(g_mpi0, g_a6400_bin, 33);
cry_mpi_load_bin(g_mpi1, g_a6400_bin, 32);
ASSERT_EQ(cry_mpi_cmp(g_mpi0, g_mpi1) > 0, 1);
ASSERT_EQ(cry_mpi_cmp(g_mpi1, g_mpi0) < 0, 1);
}
static void not_equal_sign(void)
{
cry_mpi_load_bin(g_mpi0, g_a6400_bin, 32);
cry_mpi_load_bin(g_mpi1, g_a6400_bin, 32);
g_mpi1->sign = 1; /* Set mpi1 as negative */
ASSERT_EQ(cry_mpi_cmp(g_mpi0, g_mpi1) > 0, 1);
ASSERT_EQ(cry_mpi_cmp(g_mpi1, g_mpi0) < 0, 1);
}
void mpi_cmp_test(void)
{
MPI_RUN(equal);
MPI_RUN(not_equal_same_len);
MPI_RUN(not_equal_same_len_neg);
MPI_RUN(not_equal_diff_len);
MPI_RUN(not_equal_sign);
}
#include "mpi_test.h"
static void count_bits(void)
{
ASSERT_OK(cry_mpi_load_bin(g_mpi0, g_a6400_bin, sizeof(g_a6400_bin)));
ASSERT_EQ(cry_mpi_count_bits(g_mpi0), 6400);
}
static void count_bytes(void)
{
ASSERT_OK(cry_mpi_load_bin(g_mpi0, g_a6400_bin, sizeof(g_a6400_bin)));
ASSERT_EQ(cry_mpi_count_bytes(g_mpi0), 800);
}
static void init_size(void)
{
cry_mpi tmp;
cry_mpi_init_size(&tmp, 1);
ASSERT_EQ(tmp.alloc, 1);
cry_mpi_clear(&tmp);
}
/*
* Get/Set int
*/
static void set_zero(void)
{
ASSERT_OK(cry_mpi_set_int(g_mpi0, 0));
ASSERT_EQ(cry_mpi_is_zero(g_mpi0), 1);
}
static void set_pos_int(void)
{
ASSERT_OK(cry_mpi_set_int(g_mpi0, A32_VAL));
ASSERT_EQ_MPI(g_mpi0, g_a6400_bin, cry_mpi_count_bytes(g_mpi0));
}
static void get_pos_int(void)
{
long val;
ASSERT_OK(cry_mpi_set_int(g_mpi0, A32_VAL));
ASSERT_OK(cry_mpi_get_int(g_mpi0, &val));
ASSERT_EQ(val, A32_VAL);
}
static void set_neg_int(void)
{
cry_mpi_set_int(g_mpi0, -A32_VAL);
ASSERT_EQ(cry_mpi_is_neg(g_mpi0), 1);
ASSERT_EQ_MPI(g_mpi0, g_a6400_bin, cry_mpi_count_bytes(g_mpi0));
}
static void get_neg_int(void)
{
long val;
ASSERT_OK(cry_mpi_set_int(g_mpi0, -A32_VAL));
ASSERT_OK(cry_mpi_get_int(g_mpi0, &val));
ASSERT_EQ(val, -A32_VAL);
}
static void init_int(void)
{
cry_mpi tmp;
ASSERT_OK(cry_mpi_init_int(&tmp, A32_VAL));
cry_mpi_clear(&tmp);
}
/*
* Get/Set bin
*/
static void set_bin(void)
{
long val;
ASSERT_OK(cry_mpi_load_bin(g_mpi0, g_a6400_bin, 4));
ASSERT_OK(cry_mpi_get_int(g_mpi0, &val));
ASSERT_EQ(val, A32_VAL);
}
static void get_bin(void)
{
ASSERT_OK(cry_mpi_set_int(g_mpi0, A32_VAL));
ASSERT_OK(cry_mpi_store_bin(g_mpi0, buf, BUFSIZ, 0));
ASSERT_EQ(memcmp(buf, g_a6400_bin, 4), 0);
}
static void bin_init(void)
{
cry_mpi tmp;
long val;
ASSERT_OK(cry_mpi_init_bin(&tmp, g_a6400_bin, 4));
ASSERT_OK(cry_mpi_get_int(&tmp, &val));
ASSERT_EQ(val, A32_VAL);
cry_mpi_clear(&tmp);
}
/*
* Copy
*/
static void copy_over_smaller(void)
{
ASSERT_OK(cry_mpi_load_bin(g_mpi0, g_a6400_bin, sizeof(g_a6400_bin)));
ASSERT_OK(cry_mpi_load_bin(g_mpi1, g_a6400_bin, 16));
ASSERT_OK(cry_mpi_copy(g_mpi1, g_mpi0));
ASSERT_EQ_MPI(g_mpi1, g_a6400_bin, sizeof(g_a6400_bin));
}
static void copy_over_bigger(void)
{
ASSERT_OK(cry_mpi_load_bin(g_mpi0, g_a6400_bin, 32));
ASSERT_OK(cry_mpi_load_bin(g_mpi1, g_a6400_bin, sizeof(g_a6400_bin)));
ASSERT_OK(cry_mpi_copy(g_mpi1, g_mpi0));
ASSERT_EQ_MPI(g_mpi1, g_a6400_bin, 32);
}
static void copy_over_same(void)
{
ASSERT_OK(cry_mpi_load_bin(g_mpi0, g_a6400_bin, 32));
ASSERT_OK(cry_mpi_copy(g_mpi0, g_mpi0));
}
static void copy_init(void)
{
cry_mpi tmp;
ASSERT_OK(cry_mpi_load_bin(g_mpi0, g_a6400_bin, 32));
ASSERT_OK(cry_mpi_init_copy(&tmp, g_mpi0));
ASSERT_EQ_MPI(&tmp, g_a6400_bin, 32);
cry_mpi_clear(&tmp);
}
void mpi_core_test(void)
{
MPI_RUN(count_bits);
MPI_RUN(count_bytes);
MPI_RUN(set_zero);
MPI_RUN(init_size);
/* Int */
MPI_RUN(set_pos_int);
MPI_RUN(get_pos_int);
MPI_RUN(set_neg_int);
MPI_RUN(get_neg_int);
MPI_RUN(init_int);
/* Bin */
MPI_RUN(bin_init);
MPI_RUN(set_bin);
MPI_RUN(get_bin);
/* Copy */
MPI_RUN(copy_over_smaller);
MPI_RUN(copy_over_bigger);
MPI_RUN(copy_over_same);
MPI_RUN(copy_init);
}
This diff is collapsed.
#include "mpi_test.h"
static cry_mpi a, b, r;
static size_t siz;
static void setup(void)
{
memset(buf, 0, BUFSIZ);
ASSERT_OK(cry_mpi_init_list(&a, &b, &r, NULL));
}
static void teardown(void)
{
cry_mpi_clear_list(&a, &b, &r, NULL);
}
static void simple(void)
{
ASSERT_OK(cry_mpi_set_int(&a, 0x02));
ASSERT_OK(cry_mpi_set_int(&b, 0x03));
ASSERT_OK(cry_mpi_mul(&r, &a, &b));
cry_mpi_store_bin(&r, buf, BUFSIZ, 0);
ASSERT_EQ(memcmp(buf, "\x06", 1), 0);
}
#define DIGIT_MAX_BIN "\xff\xff\xff\xff\xff\xff\xff\xff"
#define DIGIT_MAX_SIZ 8
#define DIGIT_MAX_MUL_BIN \
"\xff\xff\xff\xff\xff\xff\xff\xfe\x00\x00\x00\x00\x00\x00\x00\x01"
#define DIGIT_MAX_MUL_SIZ \
(sizeof(DIGIT_MAX_MUL_BIN)-1)
static void digit_max(void)
{
ASSERT_OK(cry_mpi_load_bin(&a, DIGIT_MAX_BIN, DIGIT_MAX_SIZ));
ASSERT_OK(cry_mpi_load_bin(&b, DIGIT_MAX_BIN, DIGIT_MAX_SIZ));
ASSERT_OK(cry_mpi_mul(&r, &a, &b));
siz = cry_mpi_store_bin(&r, (char *)buf, BUFSIZ, 0);
ASSERT_EQ(siz, DIGIT_MAX_MUL_SIZ);
ASSERT_EQ(memcmp(buf, DIGIT_MAX_MUL_BIN, DIGIT_MAX_MUL_SIZ), 0);
}
static void by_zero(void)
{
ASSERT_OK(cry_mpi_load_bin(&a, DIGIT_MAX_BIN, DIGIT_MAX_SIZ));
cry_mpi_zero(&b);
ASSERT_OK(cry_mpi_mul(&r, &a, &b));
ASSERT_EQ(cry_mpi_is_zero(&r), 1);
}
static void karatsuba(void)
{
cry_mpi c, d;
ASSERT_OK(cry_mpi_init_list(&c, &d, NULL));
ASSERT_OK(cry_mpi_load_bin(&a, g_a6400_bin, sizeof(g_a6400_bin)));
ASSERT_OK(cry_mpi_load_bin(&b, g_b6400_bin, sizeof(g_b6400_bin)));
ASSERT_OK(cry_mpi_load_bin(&c, g_a6400_b6400_mul_bin, sizeof(g_a6400_b6400_mul_bin)));
ASSERT_OK(cry_mpi_mul_karatsuba(&d, &a, &b));
ASSERT_EQ(cry_mpi_cmp(&c, &d), 0);
cry_mpi_clear_list(&a, &b, &c, &d, NULL);
}
static void comba(void)
{
cry_mpi c, d;
ASSERT_OK(cry_mpi_init_list(&c, &d, NULL));
ASSERT_OK(cry_mpi_load_bin(&a, g_a6400_bin, sizeof(g_a6400_bin)));
ASSERT_OK(cry_mpi_load_bin(&b, g_b6400_bin, sizeof(g_b6400_bin)));
ASSERT_OK(cry_mpi_load_bin(&c, g_a6400_b6400_mul_bin, sizeof(g_a6400_b6400_mul_bin)));
ASSERT_OK(cry_mpi_mul_comba(&d, &a, &b));
ASSERT_EQ(cry_mpi_cmp(&c, &d), 0);
cry_mpi_clear_list(&a, &b, &c, &d, NULL);
}
#define MYRUN(test) RUNX(test, setup, teardown)
void mpi_mul_test(void)
{
MYRUN(simple);
MYRUN(digit_max);
MYRUN(by_zero);
MYRUN(karatsuba);
MYRUN(comba);
}
#if 0
static void mpi_init_test(void)
{
cry_mpi a, b;
cry_mpi_init(&a);
PRINT_MPI("pre init", &a, 16);
cry_mpi_set_int(&a, 0x1234);
PRINT_MPI("post init", &a, 16);
cry_mpi_clear(&a);
cry_mpi_init_int(&a, 0x12345678);
cry_mpi_init_copy(&b, &a);
PRINT_MPI("after init-copy", &b, 16);
cry_mpi_clear_list(&a, &b, NULL);
cry_mpi_init_size(&a, 1);
cry_mpi_init(&b);
TRACE("with init_size(1) alloc=%d\n", a.alloc);
TRACE("with init() alloc= %d\n", b.alloc);
}
static void init_list_test(void)
{
cry_mpi a, b, c;
if (cry_mpi_init_list(&a, &b, &c, NULL) != 0)
TRACE("Error: mpi_init_list\n");
cry_mpi_clear_list(&a, &b, &c, NULL);
}
static void init_bin_test(void)
{
cry_mpi a;
int i;
const char mpi_be_data[] = {
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
};
char buf[sizeof(mpi_be_data)];
TRACE("load-bin: ");
for (i = 0; i < sizeof(mpi_be_data); i++)
TRACE("%02x", mpi_be_data[i]);
TRACE("\n");
cry_mpi_init_bin(&a, mpi_be_data, sizeof(mpi_be_data));
PRINT_MPI("a", &a, 16);
cry_mpi_store_bin(&a, buf, sizeof(buf), 1);
TRACE("store-bin (pad=1): ");
for (i = 0; i < sizeof(buf); i++)
TRACE("%02x", buf[i]);
TRACE("\n");
cry_mpi_store_bin(&a, buf, a.used, 0);
TRACE("store-bin (pad=0): ");
for (i = 0; i < a.used; i++)
TRACE("%02x", buf[i]);
TRACE("\n");
cry_mpi_clear(&a);
}
static void init_str_test(void)
{
cry_mpi a;
cry_mpi_init_str(&a, 16, "123456789abcdef");
PRINT_MPI("a", &a, 16);
ASSERT_EQ_MPI(&a, 16, "123456789abcdef");
cry_mpi_clear(&a);
cry_mpi_init_str(&a, 16, "-123456789a");
PRINT_MPI("a", &a, 16);
ASSERT_EQ_MPI(&a, 16, "-123456789a");
cry_mpi_clear(&a);
}
static void load_str_test(void)
{
cry_mpi a;
cry_mpi_init_str(&a, 16, "0123456789abcdef");
cry_mpi_store_str(&a, 16, buf, 6);
ASSERT(memcmp("1234*\x00", buf, 6) == 0);
cry_mpi_clear(&a);
}
static void abs_test(void)
{
cry_mpi a, b;
cry_mpi_init_str(&a, 16, "-123456789a");
ASSERT(a.sign != 0);
cry_mpi_init(&b);
cry_mpi_abs(&b, &a);
ASSERT(b.sign == 0);
cry_mpi_clear_list(&a, &b, NULL);
}
static void cmp_test(void)
{
cry_mpi a, b, r;
cry_mpi_init_int(&a, 0x1234);
cry_mpi_init_int(&b, 0x4321);
cry_mpi_init(&r);
PRINT_MPI("a", &a, 16);
PRINT_MPI("b", &b, 16);
TRACE("cmp(a,b) res=%d\n", cry_mpi_cmp(&a, &b));
TRACE("cmp(b,a) res=%d\n", cry_mpi_cmp(&b, &a));
cry_mpi_clear_list(&a, &b, &r, NULL);
}
static void add_test(void)
{
cry_mpi a, b, r;
cry_mpi_init_int(&a, 0x1234);
cry_mpi_init_int(&b, 0x4321);
cry_mpi_init(&r);
cry_mpi_add(&r, &a, &b);
PRINT_MPI("a", &a, 16);
PRINT_MPI("b", &b, 16);
PRINT_MPI("a + b", &r, 16);
cry_mpi_clear_list(&a, &b, &r, NULL);
}
static void sub_test(void)
{
cry_mpi a, b, r;
cry_mpi_init_int(&a, 0x55555555);
cry_mpi_init_int(&b, 0x1111);
cry_mpi_init(&r);
cry_mpi_sub(&r, &a, &b);
PRINT_MPI("a", &a, 16);
PRINT_MPI("b", &b, 16);
PRINT_MPI("a - b", &r, 16);
cry_mpi_clear_list(&a, &b, &r, NULL);
}
static void mul_test(void)
{
cry_mpi a, b, r;
cry_mpi_init_list(&a, &b, &r, NULL);
cry_mpi_set_int(&a, 0x1234);
cry_mpi_set_int(&b, 0x02);
cry_mpi_mul(&r, &a, &b);
PRINT_MPI("a", &a, 16);
PRINT_MPI("b", &b, 16);
PRINT_MPI("a * b", &r, 16);
cry_mpi_clear_list(&a, &b, &r, NULL);
}
static void div_test(void)
{
cry_mpi a, b, r, q;
cry_mpi_init_list(&a, &b, &q, &r, NULL);
cry_mpi_set_int(&a, -7);
cry_mpi_set_int(&b, 3);
cry_mpi_div(&q, &r, &a, &b);
PRINT_MPI("a", &a, 16);
PRINT_MPI("b", &b, 16);
PRINT_MPI("a / b", &q, 16);
PRINT_MPI("a \% b", &r, 16);
cry_mpi_clear_list(&a, &b, &q, &r, NULL);
}
static void shl_test(void)
{
cry_mpi a;
cry_mpi_init_str(&a, 16, "0102030405060708090a0b0c0d0e0f");
PRINT_MPI("a ", &a, 16);
cry_mpi_shl(&a, &a, 3);
PRINT_MPI("a << 3", &a, 16);
ASSERT_EQ_MPI(&a, 16, "81018202830384048505860687078");
cry_mpi_clear(&a);
}
static void shr_test(void)
{
cry_mpi a;
cry_mpi_init_str(&a, 16, "0102030405060708090a0b0c0d0e0f");
PRINT_MPI("a ", &a, 16);
cry_mpi_shr(&a, &a, 3);
PRINT_MPI("a >> 3", &a, 16);
ASSERT_EQ_MPI(&a, 16, "20406080a0c0e10121416181a1c1");
cry_mpi_clear(&a);
}
static void exp_test(void)
{
cry_mpi r, b, e;
cry_mpi_init_str(&b, 10, "123");
cry_mpi_init_str(&e, 10, "4");
cry_mpi_init(&r);
cry_mpi_exp(&r, &b, &e);
PRINT_MPI("exp(a,b)", &r, 16);
ASSERT_EQ_MPI(&r, 16, "da48871");
cry_mpi_clear_list(&r, &b, &e, NULL);
}
static void gcd_test(void)
{
cry_mpi a, b, c;
cry_mpi_init_str(&a, 10, "53667");
cry_mpi_init_str(&b, 10, "25527");
cry_mpi_init(&c);
cry_mpi_gcd(&c, &a, &b);
PRINT_MPI("gcd(a,b)", &c, 16);
ASSERT_EQ_MPI(&c, 10, "201");
cry_mpi_clear_list(&a, &b, &c, NULL);
}
static void lcm_test(void)
{
cry_mpi a, b, c;
cry_mpi_init_str(&a, 10, "53667");
cry_mpi_init_str(&b, 10, "25527");
cry_mpi_init(&c);
cry_mpi_lcm(&c, &a, &b);
PRINT_MPI("lcm(a,b)", &c, 16);
ASSERT_EQ_MPI(&c, 10, "6815709");
cry_mpi_clear_list(&a, &b, &c, NULL);
}
static void inv_test(void)
{
cry_mpi a, b, c;
ASSERT_EQ(cry_mpi_init_int(&a, 7), 0);
ASSERT_EQ(cry_mpi_init_int(&b, 15), 0);
ASSERT_EQ(cry_mpi_init(&c), 0);
ASSERT_EQ(cry_mpi_inv(&c, &a, &b), 0);