Skip to content

Commit

Permalink
Extend scope of tests to remove blindness
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Mason committed Apr 11, 2024
1 parent db8fd4d commit 91cd20c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/decimal_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2968,6 +2968,7 @@ fn it_converts_from_i128() {
(0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF, Some("79228162514264337593543950335")),
(0x7FFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF, None),
(i128::MIN, None),
(i128::MAX, None),
];
for (value, expected) in tests {
let from_i128 = num_traits::FromPrimitive::from_i128(*value);
Expand All @@ -2989,11 +2990,17 @@ fn it_converts_from_u128() {
(0xFFFF_FFFF_FFFF_FFFF, Some("18446744073709551615")),
(0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF, Some("79228162514264337593543950335")),
(0x7FFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF, None),
(u128::MAX, None),
];
for (value, expected) in tests {
if let Some(expected_value) = expected {
let decimal = Decimal::from_str(expected_value).unwrap();
assert_eq!(num_traits::FromPrimitive::from_u128(*value), Some(decimal));
let from_u128 = num_traits::FromPrimitive::from_u128(*value);

match expected {
Some(expected_value) => {
let decimal = Decimal::from_str(expected_value).unwrap();
assert_eq!(from_u128, Some(decimal));
}
None => assert!(from_u128.is_none()),
}
}
}
Expand Down

0 comments on commit 91cd20c

Please sign in to comment.