mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-25 12:55:48 +00:00
Make sure fixed arithmetic tests don't rely on debug assertions (#6126)
This commit is contained in:
@@ -659,13 +659,6 @@ macro_rules! implement_fixed {
|
|||||||
assert_eq!(to_bound::<_, _, u32>(a, b), 0);
|
assert_eq!(to_bound::<_, _, u32>(a, b), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[should_panic(expected = "attempt to negate with overflow")]
|
|
||||||
fn op_neg_panics() {
|
|
||||||
let a = $name::min_value();
|
|
||||||
let _ = -a;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn op_neg_works() {
|
fn op_neg_works() {
|
||||||
let a = $name::saturating_from_integer(5);
|
let a = $name::saturating_from_integer(5);
|
||||||
@@ -700,11 +693,10 @@ macro_rules! implement_fixed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "attempt to add with overflow")]
|
fn op_checked_add_overflow_works() {
|
||||||
fn op_add_panics() {
|
|
||||||
let a = $name::max_value();
|
let a = $name::max_value();
|
||||||
let b = 1.into();
|
let b = 1.into();
|
||||||
let _ = a + b;
|
assert!(a.checked_add(&b).is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -722,11 +714,10 @@ macro_rules! implement_fixed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "attempt to subtract with overflow")]
|
fn op_checked_sub_underflow_works() {
|
||||||
fn op_sub_panics() {
|
|
||||||
let a = $name::min_value();
|
let a = $name::min_value();
|
||||||
let b = 1.into();
|
let b = 1.into();
|
||||||
let _c = a - b;
|
assert!(a.checked_sub(&b).is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -744,11 +735,10 @@ macro_rules! implement_fixed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "attempt to multiply with overflow")]
|
fn op_checked_mul_overflow_works() {
|
||||||
fn op_mul_panics() {
|
|
||||||
let a = $name::max_value();
|
let a = $name::max_value();
|
||||||
let b = 2.into();
|
let b = 2.into();
|
||||||
let _c = a * b;
|
assert!(a.checked_mul(&b).is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -771,11 +761,10 @@ macro_rules! implement_fixed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "attempt to divide with overflow")]
|
fn op_checked_div_overflow_works() {
|
||||||
fn op_div_panics_on_overflow() {
|
|
||||||
let a = $name::min_value();
|
let a = $name::min_value();
|
||||||
let b = (-1).into();
|
let b = (-1).into();
|
||||||
let _c = a / b;
|
assert!(a.checked_div(&b).is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user