add tests
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
diff --git a/demo/demo.c b/demo/demo.c
index f9921ec..91b8104 100644
--- a/demo/demo.c
+++ b/demo/demo.c
@@ -97,6 +97,7 @@ int main(void)
char* ret;
#else
unsigned long s, t;
+ unsigned long long q, r;
mp_digit mp;
int i, n, err;
#endif
@@ -201,6 +202,26 @@ printf("compare no compare!\n"); return EXIT_FAILURE; }
} 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
printf("\n\nTesting: mp_sqrt\n");
for (i = 0; i < 1000; ++i) {