add Num.toNat

This commit is contained in:
Brendan Hansknecht 2022-03-11 11:13:01 -08:00
parent 4e3c3ee045
commit d681062c63
6 changed files with 48 additions and 2 deletions

View file

@ -2179,6 +2179,12 @@ to_int_tests! {
to_u128_same_width, "15i128", 15
to_u128_extend, "15i8", 15
)
"Num.toNat", usize, (
to_nat_same_width, "15i64", 15, ["gen-wasm"]
to_nat_extend, "15i8", 15, ["gen-wasm"]
to_nat_truncate, "115i128", 115
to_nat_truncate_wraps, "10_000_000_000_000_000_000_000i128", 1864712049423024128
)
}
macro_rules! to_int_checked_tests {
@ -2312,6 +2318,18 @@ to_int_checked_tests! {
to_u128_checked_same_width_signed_fits, "15i128", 15
to_u128_checked_same_width_signed_oob, "-1i128", None
)
"Num.toNatChecked", usize, (
to_nat_checked_smaller_width_pos, "15i8", 15
to_nat_checked_smaller_width_neg_oob, "-15i8", None
to_nat_checked_same, "15u64", 15
to_nat_checked_same_width_signed_fits, "15i64", 15
to_nat_checked_same_width_signed_oob, "-1i64", None
to_nat_checked_larger_width_signed_fits_pos, "15i128", 15
to_nat_checked_larger_width_signed_oob_pos, "18446744073709551616i128", None
to_nat_checked_larger_width_signed_oob_neg, "-1i128", None
to_nat_checked_larger_width_unsigned_fits_pos, "15u128", 15
to_nat_checked_larger_width_unsigned_oob_pos, "18446744073709551616u128", None
)
}
#[test]