Skip to content

Commit

Permalink
Added cast for signed integers.
Browse files Browse the repository at this point in the history
commit-id:c56d4b74
  • Loading branch information
orizi committed Oct 2, 2023
1 parent ccf0ee3 commit 38995da
Show file tree
Hide file tree
Showing 7 changed files with 1,208 additions and 111 deletions.
155 changes: 128 additions & 27 deletions corelib/src/integer.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -1586,32 +1586,133 @@ extern fn downcast<FromType, ToType>(x: FromType) -> Option<ToType> implicits(Ra
// Marks `FromType` as upcastable to `ToType`.
// Do not add user code implementing this trait.
trait Upcastable<FromType, ToType>;
impl UpcastableU8U16 of Upcastable<u8, u16> {}
impl UpcastableU8U32 of Upcastable<u8, u32> {}
impl UpcastableU8U64 of Upcastable<u8, u64> {}
impl UpcastableU8U128 of Upcastable<u8, u128> {}
impl UpcastableU16U32 of Upcastable<u16, u32> {}
impl UpcastableU16U64 of Upcastable<u16, u64> {}
impl UpcastableU16U128 of Upcastable<u16, u128> {}
impl UpcastableU32U64 of Upcastable<u32, u64> {}
impl UpcastableU32U128 of Upcastable<u32, u128> {}
impl UpcastableU64U128 of Upcastable<u64, u128> {}
impl UpcastableU8U16 of Upcastable<u8, u16>;
impl UpcastableU8I16 of Upcastable<u8, i16>;
impl UpcastableU8U32 of Upcastable<u8, u32>;
impl UpcastableU8I32 of Upcastable<u8, i32>;
impl UpcastableU8U64 of Upcastable<u8, u64>;
impl UpcastableU8I64 of Upcastable<u8, i64>;
impl UpcastableU8U128 of Upcastable<u8, u128>;
impl UpcastableU8I128 of Upcastable<u8, i128>;
impl UpcastableI8I16 of Upcastable<i8, i16>;
impl UpcastableI8I32 of Upcastable<i8, i32>;
impl UpcastableI8I64 of Upcastable<i8, i64>;
impl UpcastableI8I128 of Upcastable<i8, i128>;
impl UpcastableU16U32 of Upcastable<u16, u32>;
impl UpcastableU16I32 of Upcastable<u16, i32>;
impl UpcastableU16U64 of Upcastable<u16, u64>;
impl UpcastableU16I64 of Upcastable<u16, i64>;
impl UpcastableU16U128 of Upcastable<u16, u128>;
impl UpcastableU16I128 of Upcastable<u16, i128>;
impl UpcastableI16I32 of Upcastable<i16, i32>;
impl UpcastableI16I64 of Upcastable<i16, i64>;
impl UpcastableI16I128 of Upcastable<i16, i128>;
impl UpcastableU32U64 of Upcastable<u32, u64>;
impl UpcastableU32I64 of Upcastable<u32, i64>;
impl UpcastableU32U128 of Upcastable<u32, u128>;
impl UpcastableU32I128 of Upcastable<u32, i128>;
impl UpcastableI32I64 of Upcastable<i32, i64>;
impl UpcastableI32I128 of Upcastable<i32, i128>;
impl UpcastableU64U128 of Upcastable<u64, u128>;
impl UpcastableU64I128 of Upcastable<u64, i128>;
impl UpcastableI64I128 of Upcastable<i64, i128>;
// Marks `FromType` as downcastable to `ToType`.
// Do not add user code implementing this trait.
trait Downcastable<FromType, ToType>;
impl DowncastableU128U64 of Downcastable<u128, u64> {}
impl DowncastableU128U32 of Downcastable<u128, u32> {}
impl DowncastableU128U16 of Downcastable<u128, u16> {}
impl DowncastableU128U8 of Downcastable<u128, u8> {}

impl DowncastableU64U32 of Downcastable<u64, u32> {}
impl DowncastableU64U16 of Downcastable<u64, u16> {}
impl DowncastableU64U8 of Downcastable<u64, u8> {}

impl DowncastableU32U16 of Downcastable<u32, u16> {}
impl DowncastableU32U8 of Downcastable<u32, u8> {}

impl DowncastableU16U8 of Downcastable<u16, u8> {}
impl DowncastableU8I8 of Downcastable<u8, i8>;
impl DowncastableU8I16 of Downcastable<u8, i16>;
impl DowncastableU8U16 of Downcastable<u8, u16>;
impl DowncastableU8I32 of Downcastable<u8, i32>;
impl DowncastableU8U32 of Downcastable<u8, u32>;
impl DowncastableU8I64 of Downcastable<u8, i64>;
impl DowncastableU8U64 of Downcastable<u8, u64>;
impl DowncastableU8I128 of Downcastable<u8, i128>;
impl DowncastableU8U128 of Downcastable<u8, u128>;
impl DowncastableI8U8 of Downcastable<i8, u8>;
impl DowncastableI8I16 of Downcastable<i8, i16>;
impl DowncastableI8U16 of Downcastable<i8, u16>;
impl DowncastableI8I32 of Downcastable<i8, i32>;
impl DowncastableI8U32 of Downcastable<i8, u32>;
impl DowncastableI8I64 of Downcastable<i8, i64>;
impl DowncastableI8U64 of Downcastable<i8, u64>;
impl DowncastableI8I128 of Downcastable<i8, i128>;
impl DowncastableI8U128 of Downcastable<i8, u128>;

impl DowncastableU16I8 of Downcastable<u16, i8>;
impl DowncastableU16U8 of Downcastable<u16, u8>;
impl DowncastableU16I16 of Downcastable<u16, i16>;
impl DowncastableU16I32 of Downcastable<u16, i32>;
impl DowncastableU16U32 of Downcastable<u16, u32>;
impl DowncastableU16I64 of Downcastable<u16, i64>;
impl DowncastableU16U64 of Downcastable<u16, u64>;
impl DowncastableU16I128 of Downcastable<u16, i128>;
impl DowncastableU16U128 of Downcastable<u16, u128>;
impl DowncastableI16I8 of Downcastable<i16, i8>;
impl DowncastableI16U8 of Downcastable<i16, u8>;
impl DowncastableI16U16 of Downcastable<i16, u16>;
impl DowncastableI16I32 of Downcastable<i16, i32>;
impl DowncastableI16U32 of Downcastable<i16, u32>;
impl DowncastableI16I64 of Downcastable<i16, i64>;
impl DowncastableI16U64 of Downcastable<i16, u64>;
impl DowncastableI16I128 of Downcastable<i16, i128>;
impl DowncastableI16U128 of Downcastable<i16, u128>;

impl DowncastableU32I8 of Downcastable<u32, i8>;
impl DowncastableU32U8 of Downcastable<u32, u8>;
impl DowncastableU32I16 of Downcastable<u32, i16>;
impl DowncastableU32U16 of Downcastable<u32, u16>;
impl DowncastableU32I32 of Downcastable<u32, i32>;
impl DowncastableU32I64 of Downcastable<u32, i64>;
impl DowncastableU32U64 of Downcastable<u32, u64>;
impl DowncastableU32I128 of Downcastable<u32, i128>;
impl DowncastableU32U128 of Downcastable<u32, u128>;
impl DowncastableI32I8 of Downcastable<i32, i8>;
impl DowncastableI32U8 of Downcastable<i32, u8>;
impl DowncastableI32I16 of Downcastable<i32, i16>;
impl DowncastableI32U16 of Downcastable<i32, u16>;
impl DowncastableI32U32 of Downcastable<i32, u32>;
impl DowncastableI32I64 of Downcastable<i32, i64>;
impl DowncastableI32U64 of Downcastable<i32, u64>;
impl DowncastableI32I128 of Downcastable<i32, i128>;
impl DowncastableI32U128 of Downcastable<i32, u128>;

impl DowncastableU64I8 of Downcastable<u64, i8>;
impl DowncastableU64U8 of Downcastable<u64, u8>;
impl DowncastableU64I16 of Downcastable<u64, i16>;
impl DowncastableU64U16 of Downcastable<u64, u16>;
impl DowncastableU64I32 of Downcastable<u64, i32>;
impl DowncastableU64U32 of Downcastable<u64, u32>;
impl DowncastableU64I64 of Downcastable<u64, i64>;
impl DowncastableU64I128 of Downcastable<u64, i128>;
impl DowncastableU64U128 of Downcastable<u64, u128>;
impl DowncastableI64I8 of Downcastable<i64, i8>;
impl DowncastableI64U8 of Downcastable<i64, u8>;
impl DowncastableI64I16 of Downcastable<i64, i16>;
impl DowncastableI64U16 of Downcastable<i64, u16>;
impl DowncastableI64I32 of Downcastable<i64, i32>;
impl DowncastableI64U32 of Downcastable<i64, u32>;
impl DowncastableI64U64 of Downcastable<i64, u64>;
impl DowncastableI64I128 of Downcastable<i64, i128>;
impl DowncastableI64U128 of Downcastable<i64, u128>;

impl DowncastableU128I8 of Downcastable<u128, i8>;
impl DowncastableU128U8 of Downcastable<u128, u8>;
impl DowncastableU128I16 of Downcastable<u128, i16>;
impl DowncastableU128U16 of Downcastable<u128, u16>;
impl DowncastableU128I32 of Downcastable<u128, i32>;
impl DowncastableU128U32 of Downcastable<u128, u32>;
impl DowncastableU128I64 of Downcastable<u128, i64>;
impl DowncastableU128U64 of Downcastable<u128, u64>;
impl DowncastableU128I128 of Downcastable<u128, i128>;
impl DowncastableI128I8 of Downcastable<i128, i8>;
impl DowncastableI128U8 of Downcastable<i128, u8>;
impl DowncastableI128I16 of Downcastable<i128, i16>;
impl DowncastableI128U16 of Downcastable<i128, u16>;
impl DowncastableI128I32 of Downcastable<i128, i32>;
impl DowncastableI128U32 of Downcastable<i128, u32>;
impl DowncastableI128I64 of Downcastable<i128, i64>;
impl DowncastableI128U64 of Downcastable<i128, u64>;
impl DowncastableI128U128 of Downcastable<i128, u128>;

/// Default values
impl U8Default of Default<u8> {
Expand Down Expand Up @@ -1958,7 +2059,7 @@ impl I8Neg of Neg<i8> {
extern fn i8_wide_mul(lhs: i8, rhs: i8) -> i16 implicits() nopanic;
impl I8Mul of Mul<i8> {
fn mul(lhs: i8, rhs: i8) -> i8 {
i8_try_from_felt252(i16_to_felt252(i8_wide_mul(lhs, rhs))).expect('i8_mul Overflow')
i8_wide_mul(lhs, rhs).try_into().expect('i8_mul Overflow')
}
}
impl I8MulEq of MulEq<i8> {
Expand Down Expand Up @@ -2059,7 +2160,7 @@ impl I16Neg of Neg<i16> {
extern fn i16_wide_mul(lhs: i16, rhs: i16) -> i32 implicits() nopanic;
impl I16Mul of Mul<i16> {
fn mul(lhs: i16, rhs: i16) -> i16 {
i16_try_from_felt252(i32_to_felt252(i16_wide_mul(lhs, rhs))).expect('i16_mul Overflow')
i16_wide_mul(lhs, rhs).try_into().expect('i16_mul Overflow')
}
}
impl I16MulEq of MulEq<i16> {
Expand Down Expand Up @@ -2160,7 +2261,7 @@ impl I32Neg of Neg<i32> {
extern fn i32_wide_mul(lhs: i32, rhs: i32) -> i64 implicits() nopanic;
impl I32Mul of Mul<i32> {
fn mul(lhs: i32, rhs: i32) -> i32 {
i32_try_from_felt252(i64_to_felt252(i32_wide_mul(lhs, rhs))).expect('i32_mul Overflow')
i32_wide_mul(lhs, rhs).try_into().expect('i32_mul Overflow')
}
}
impl I32MulEq of MulEq<i32> {
Expand Down Expand Up @@ -2261,7 +2362,7 @@ impl I64Neg of Neg<i64> {
extern fn i64_wide_mul(lhs: i64, rhs: i64) -> i128 implicits() nopanic;
impl I64Mul of Mul<i64> {
fn mul(lhs: i64, rhs: i64) -> i64 {
i64_try_from_felt252(i128_to_felt252(i64_wide_mul(lhs, rhs))).expect('i64_mul Overflow')
i64_wide_mul(lhs, rhs).try_into().expect('i64_mul Overflow')
}
}
impl I64MulEq of MulEq<i64> {
Expand Down
184 changes: 162 additions & 22 deletions corelib/src/test/integer_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -931,39 +931,179 @@ fn test_u256_try_into_felt252() {
assert(f.is_none(), 'prime+2**128 is not felt252');
}

fn cast_must_pass<
/// Checks if `b` is out of range of `A`.
fn is_out_of_range<A, B, +Drop<A>, +TryInto<B, A>>(b: B) -> bool {
let no_a: Option<A> = b.try_into();
no_a.is_none()
}

/// Checks if `a` is trivially castable to `B` and that `b` is castable to `A`, with the same value.
fn cast_subtype_valid<
SubType,
SuperType,
+Drop<SubType>,
+Drop<SuperType>,
+Copy<SubType>,
+Copy<SuperType>,
+BoundedInt<SubType>,
+PartialEq<SubType>,
+PartialEq<SuperType>,
+Into<SubType, SuperType>,
+TryInto<SuperType, SubType>
>() -> bool {
let max_sub: SubType = BoundedInt::max();
let max_sub_as_super: SuperType = max_sub.into();
let min_sub: SubType = BoundedInt::min();
let min_sub_as_super: SuperType = min_sub.into();
min_sub_as_super.try_into().unwrap() == min_sub
&& max_sub_as_super.try_into().unwrap() == max_sub
}

#[derive(Drop)]
enum EdgeConfig {
OfBoth,
OfAOnly,
OfBOnly,
}

/// Checks that casting from `A` to `B` are valid around the bounds.
fn validate_cast_bounds<
A,
B,
+Drop<A>,
+Drop<B>,
+Copy<B>,
+Copy<A>,
+PartialEq<A>,
+PartialEq<B>,
+Copy<B>,
+BoundedInt<A>,
+BoundedInt<B>,
+Into<A, B>,
+TryInto<B, A>
+Add<A>,
+Add<B>,
+Sub<A>,
+Sub<B>,
+PartialEq<A>,
+PartialEq<B>,
+TryInto<A, B>,
+TryInto<B, A>,
+TryInto<felt252, A>,
+TryInto<felt252, B>,
>(
ui: A, uj: B
) -> bool {
uj == ui.into()
&& ui == uj.try_into().unwrap()
&& BoundedInt::<B>::min() == BoundedInt::<A>::min().into()
&& BoundedInt::<A>::min() == BoundedInt::<B>::min().try_into().unwrap()
min_cfg: EdgeConfig, max_cfg: EdgeConfig, err: felt252,
) {
let one_as_a: A = 1.try_into().unwrap();
let one_as_b: B = 1.try_into().unwrap();
let min_a: A = BoundedInt::min();
let min_b: B = BoundedInt::min();
let max_a: A = BoundedInt::max();
let max_b: B = BoundedInt::max();
match min_cfg {
EdgeConfig::OfBoth => {
assert(Option::Some(min_a) == min_b.try_into(), err);
assert(Option::Some(min_b) == min_a.try_into(), err);
},
EdgeConfig::OfAOnly => {
let min_a_as_b: B = min_a.try_into().expect(err);
assert(Option::Some(min_a) == min_a_as_b.try_into(), err);
assert(is_out_of_range::<A>(min_a_as_b - one_as_b), err);
},
EdgeConfig::OfBOnly => {
let min_b: B = BoundedInt::min();
let min_b_as_a: A = min_b.try_into().expect(err);
assert(Option::Some(min_b) == min_b_as_a.try_into(), err);
assert(is_out_of_range::<B>(min_b_as_a - one_as_a), err);
},
}
match max_cfg {
EdgeConfig::OfBoth => {
assert(Option::Some(max_a) == max_b.try_into(), err);
assert(Option::Some(max_b) == max_a.try_into(), err);
},
EdgeConfig::OfAOnly => {
let max_a_as_b: B = max_a.try_into().expect(err);
assert(Option::Some(max_a) == max_a_as_b.try_into(), err);
assert(is_out_of_range::<A>(max_a_as_b + one_as_b), err);
},
EdgeConfig::OfBOnly => {
let max_b_as_a: A = max_b.try_into().expect(err);
assert(Option::Some(max_b) == max_b_as_a.try_into(), err);
assert(is_out_of_range::<B>(max_b_as_a + one_as_a), err);
},
}
}

#[test]
fn proper_cast() {
assert(cast_must_pass(0xFF_u8, 0xFF_u16), 'u8 to_and_fro u16');
assert(cast_must_pass(0xFF_u8, 0xFF_u32), 'u8 to_and_fro u32');
assert(cast_must_pass(0xFF_u8, 0xFF_u64), 'u8 to_and_fro u64');
assert(cast_must_pass(0xFF_u8, 0xFF_u128), 'u8 to_and_fro u128');
assert(cast_must_pass(0xFFFF_u16, 0xFFFF_u32), 'u16 to_and_fro u32');
assert(cast_must_pass(0xFFFF_u16, 0xFFFF_u64), 'u16 to_and_fro u64');
assert(cast_must_pass(0xFFFF_u16, 0xFFFF_u128), 'u16 to_and_fro u128');
assert(cast_must_pass(0xFFFFFFFF_u32, 0xFFFFFFFF_u64), 'u32 to_and_fro u64');
assert(cast_must_pass(0xFFFFFFFF_u32, 0xFFFFFFFF_u128), 'u32 to_and_fro u128');
assert(cast_must_pass(0xFFFFFFFFFFFFFFFF_u64, 0xFFFFFFFFFFFFFFFF_u128), 'u64 to_and_fro u128');
assert(cast_subtype_valid::<u8, u16>(), 'u8 as u16 subtype');
assert(cast_subtype_valid::<u8, u32>(), 'u8 as u32 subtype');
assert(cast_subtype_valid::<u8, u64>(), 'u8 as u64 subtype');
assert(cast_subtype_valid::<u8, u128>(), 'u8 as u128 subtype');
assert(cast_subtype_valid::<u8, i16>(), 'u8 as i16 subtype');
assert(cast_subtype_valid::<u8, i32>(), 'u8 as i32 subtype');
assert(cast_subtype_valid::<u8, i64>(), 'u8 as i64 subtype');
assert(cast_subtype_valid::<u8, i128>(), 'u8 as i128 subtype');
assert(cast_subtype_valid::<i8, i16>(), 'i8 as i16 subtype');
assert(cast_subtype_valid::<i8, i32>(), 'i8 as i32 subtype');
assert(cast_subtype_valid::<i8, i64>(), 'i8 as i64 subtype');
assert(cast_subtype_valid::<i8, i128>(), 'i8 as i128 subtype');

assert(cast_subtype_valid::<u16, u32>(), 'u16 as u32 subtype');
assert(cast_subtype_valid::<u16, u64>(), 'u16 as u64 subtype');
assert(cast_subtype_valid::<u16, u128>(), 'u16 as u128 subtype');
assert(cast_subtype_valid::<u16, i32>(), 'u16 as i32 subtype');
assert(cast_subtype_valid::<u16, i64>(), 'u16 as i64 subtype');
assert(cast_subtype_valid::<u16, i128>(), 'u16 as i128 subtype');
assert(cast_subtype_valid::<i16, i32>(), 'i16 as i32 subtype');
assert(cast_subtype_valid::<i16, i64>(), 'i16 as i64 subtype');
assert(cast_subtype_valid::<i16, i128>(), 'i16 as i128 subtype');

assert(cast_subtype_valid::<u32, u64>(), 'u32 as u64 subtype');
assert(cast_subtype_valid::<u32, u128>(), 'u32 as u128 subtype');
assert(cast_subtype_valid::<u32, i64>(), 'u32 as i64 subtype');
assert(cast_subtype_valid::<u32, i128>(), 'u32 as i128 subtype');
assert(cast_subtype_valid::<i32, i64>(), 'i32 as i64 subtype');
assert(cast_subtype_valid::<i32, i128>(), 'i32 as i128 subtype');

assert(cast_subtype_valid::<u64, u128>(), 'u64 as u128 subtype');
assert(cast_subtype_valid::<u64, i128>(), 'u64 as i128 subtype');
assert(cast_subtype_valid::<i64, i128>(), 'i64 as i128 subtype');

validate_cast_bounds::<u8, u16>(EdgeConfig::OfBoth, EdgeConfig::OfAOnly, 'u8 u16 cast');
validate_cast_bounds::<u8, u32>(EdgeConfig::OfBoth, EdgeConfig::OfAOnly, 'u8 u32 cast');
validate_cast_bounds::<u8, u64>(EdgeConfig::OfBoth, EdgeConfig::OfAOnly, 'u8 u64 cast');
validate_cast_bounds::<u8, u128>(EdgeConfig::OfBoth, EdgeConfig::OfAOnly, 'u8 u128 cast');
validate_cast_bounds::<u16, u32>(EdgeConfig::OfBoth, EdgeConfig::OfAOnly, 'u16 u32 cast');
validate_cast_bounds::<u16, u64>(EdgeConfig::OfBoth, EdgeConfig::OfAOnly, 'u16 u64 cast');
validate_cast_bounds::<u16, u128>(EdgeConfig::OfBoth, EdgeConfig::OfAOnly, 'u16 u128 cast');
validate_cast_bounds::<u32, u64>(EdgeConfig::OfBoth, EdgeConfig::OfAOnly, 'u32 u64 cast');
validate_cast_bounds::<u32, u128>(EdgeConfig::OfBoth, EdgeConfig::OfAOnly, 'u32 u128 cast');
validate_cast_bounds::<u64, u128>(EdgeConfig::OfBoth, EdgeConfig::OfAOnly, 'u64 u128 cast');

validate_cast_bounds::<i8, i16>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'i8 i16 cast');
validate_cast_bounds::<i8, i32>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'i8 i32 cast');
validate_cast_bounds::<i8, i64>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'i8 i64 cast');
validate_cast_bounds::<i8, i128>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'i8 i128 cast');
validate_cast_bounds::<i16, i32>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'i16 i32 cast');
validate_cast_bounds::<i16, i64>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'i16 i64 cast');
validate_cast_bounds::<i16, i128>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'i16 i128 cast');
validate_cast_bounds::<i32, i64>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'i32 i64 cast');
validate_cast_bounds::<i32, i128>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'i32 i128 cast');
validate_cast_bounds::<i64, i128>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'i64 i128 cast');

validate_cast_bounds::<u8, i16>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'u8 i16 cast');
validate_cast_bounds::<u8, i32>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'u8 i32 cast');
validate_cast_bounds::<u8, i64>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'u8 i64 cast');
validate_cast_bounds::<u8, i128>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'u8 i128 cast');
validate_cast_bounds::<u16, i32>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'u16 i32 cast');
validate_cast_bounds::<u16, i64>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'u16 i64 cast');
validate_cast_bounds::<u16, i128>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'u16 i128 cast');
validate_cast_bounds::<u32, i64>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'u32 i64 cast');
validate_cast_bounds::<u32, i128>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'u32 i128 cast');
validate_cast_bounds::<u64, i128>(EdgeConfig::OfAOnly, EdgeConfig::OfAOnly, 'u64 i128 cast');

validate_cast_bounds::<u8, i8>(EdgeConfig::OfAOnly, EdgeConfig::OfBOnly, 'u8 i8 cast');
validate_cast_bounds::<u16, i16>(EdgeConfig::OfAOnly, EdgeConfig::OfBOnly, 'u16 i16 cast');
validate_cast_bounds::<u32, i32>(EdgeConfig::OfAOnly, EdgeConfig::OfBOnly, 'u32 i32 cast');
validate_cast_bounds::<u64, i64>(EdgeConfig::OfAOnly, EdgeConfig::OfBOnly, 'u64 i64 cast');
validate_cast_bounds::<u128, i128>(EdgeConfig::OfAOnly, EdgeConfig::OfBOnly, 'u128 i128 cast');
}

#[test]
Expand Down
Loading

0 comments on commit 38995da

Please sign in to comment.