1 | /* Regression test for mp_int_swap() bug on self-stored values. */ |
---|---|
2 | #include <stdio.h> |
3 | #include "imath.h" |
4 | |
5 | int main(int argc, char* argv[]) { |
6 | mpz_t a, b; |
7 | int result; |
8 | |
9 | mp_int_init_value(z: &a, value: 1); |
10 | mp_int_init_value(z: &b, value: 16); |
11 | |
12 | mp_int_swap(a: &a, c: &b); |
13 | result = (a.digits == &(a.single) && b.digits == &(b.single) && |
14 | a.digits[0] == 16 && b.digits[0] == 1); |
15 | |
16 | printf(format: "REGRESSION: mp_int_swap() on self-stored values: %s\n", |
17 | result ? "OK": "FAILED"); |
18 | |
19 | mp_int_clear(z: &b); |
20 | mp_int_clear(z: &a); |
21 | return !result; |
22 | } |
23 |