Commit 0e1a0e6529cb896ebca497f547d00916f1874217

Steffen Jaeckel 2019-05-24T11:27:03

also test mp_shrink()

diff --git a/demo/test.c b/demo/test.c
index c8b696a..8c67e25 100644
--- a/demo/test.c
+++ b/demo/test.c
@@ -137,7 +137,11 @@ LBL_ERR:
 
 static int check_get_set_i32(mp_int *a, int32_t b)
 {
+   mp_clear(a);
+   if (mp_shrink(a) != MP_OKAY) return EXIT_FAILURE;
+
    mp_set_i32(a, b);
+   if (mp_shrink(a) != MP_OKAY) return EXIT_FAILURE;
    if (mp_get_i32(a) != b) return EXIT_FAILURE;
    if (mp_get_u32(a) != (uint32_t)b) return EXIT_FAILURE;
    if (mp_get_mag32(a) != uabs32(b)) return EXIT_FAILURE;
@@ -180,7 +184,11 @@ LBL_ERR:
 
 static int check_get_set_i64(mp_int *a, int64_t b)
 {
+   mp_clear(a);
+   if (mp_shrink(a) != MP_OKAY) return EXIT_FAILURE;
+
    mp_set_i64(a, b);
+   if (mp_shrink(a) != MP_OKAY) return EXIT_FAILURE;
    if (mp_get_i64(a) != b) return EXIT_FAILURE;
    if (mp_get_u64(a) != (uint64_t)b) return EXIT_FAILURE;
    if (mp_get_mag64(a) != uabs64(b)) return EXIT_FAILURE;