diff options
Diffstat (limited to 'unix/coverage.c')
-rw-r--r-- | unix/coverage.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/unix/coverage.c b/unix/coverage.c index 1f52d9cf8..d6514b9cf 100644 --- a/unix/coverage.c +++ b/unix/coverage.c @@ -3,6 +3,7 @@ #include "py/obj.h" #include "py/runtime.h" #include "py/repl.h" +#include "py/mpz.h" #if defined(MICROPY_UNIX_COVERAGE) @@ -83,6 +84,29 @@ STATIC mp_obj_t extra_coverage(void) { printf("%d\n", MP_OBJ_IS_QSTR(mp_obj_str_intern(mp_obj_new_str("intern me", 9, false)))); } + // mpz + { + printf("# mpz\n"); + + mp_uint_t value; + mpz_t mpz; + mpz_init_zero(&mpz); + + // mpz_as_uint_checked, with success + mpz_set_from_int(&mpz, 12345678); + printf("%d\n", mpz_as_uint_checked(&mpz, &value)); + printf("%d\n", (int)value); + + // mpz_as_uint_checked, with negative arg + mpz_set_from_int(&mpz, -1); + printf("%d\n", mpz_as_uint_checked(&mpz, &value)); + + // mpz_as_uint_checked, with overflowing arg + mpz_set_from_int(&mpz, 1); + mpz_shl_inpl(&mpz, &mpz, 70); + printf("%d\n", mpz_as_uint_checked(&mpz, &value)); + } + return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_0(extra_coverage_obj, extra_coverage); |