add tests
This commit is contained in:
parent
0e3d3ad29d
commit
9d83fce77e
21
demo/demo.c
21
demo/demo.c
@ -97,6 +97,7 @@ int main(void)
|
|||||||
char* ret;
|
char* ret;
|
||||||
#else
|
#else
|
||||||
unsigned long s, t;
|
unsigned long s, t;
|
||||||
|
unsigned long long q, r;
|
||||||
mp_digit mp;
|
mp_digit mp;
|
||||||
int i, n, err;
|
int i, n, err;
|
||||||
#endif
|
#endif
|
||||||
@ -201,6 +202,26 @@ printf("compare no compare!\n"); return EXIT_FAILURE; }
|
|||||||
} while(t);
|
} while(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("\n\nTesting: mp_get_long_long\n");
|
||||||
|
for (i = 0; i < (int)sizeof(unsigned long long)*CHAR_BIT; ++i) {
|
||||||
|
r = (1ULL << (i+1)) - 1;
|
||||||
|
if (!r)
|
||||||
|
r = -1;
|
||||||
|
printf(" r = 0x%llx i = %d\r", r, i);
|
||||||
|
do {
|
||||||
|
if (mp_set_long_long(&a, r) != MP_OKAY) {
|
||||||
|
printf("\nmp_set_long_long() error!");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
q = mp_get_long_long(&a);
|
||||||
|
if (q != r) {
|
||||||
|
printf("\nmp_get_long_long() bad result! 0x%llx != 0x%llx", q, r);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
r <<= 1;
|
||||||
|
} while(r);
|
||||||
|
}
|
||||||
|
|
||||||
// test mp_sqrt
|
// test mp_sqrt
|
||||||
printf("\n\nTesting: mp_sqrt\n");
|
printf("\n\nTesting: mp_sqrt\n");
|
||||||
for (i = 0; i < 1000; ++i) {
|
for (i = 0; i < 1000; ++i) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user