Skip to content

Commit

Permalink
Testing checked_div in walkthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
wojciech-cichocki committed Oct 11, 2023
1 parent aee8580 commit febdad9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/walkthrough.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ mod walkthrough {
let result = percentage.checked_sub(Percentage::new(10));
assert_eq!(result, Ok(Percentage::new(90)));
}

// checked_div
{
let result = Price::from_integer(99).checked_div(Price::from_scale(5, 1));
assert_eq!(result, Ok(Price::from_integer(198)));
}
// checked_from_scale
{
let overflow_err =
Expand All @@ -104,7 +108,8 @@ mod walkthrough {
}
// checked_from_scale_to_value
{
let result = Price::checked_from_scale_to_value(max_price_value, price_scale - 1).unwrap();
let result =
Price::checked_from_scale_to_value(max_price_value, price_scale - 1).unwrap();
assert_eq!(
result,
U256::from_dec_str("3402823669209384634633746074317682114550").unwrap()
Expand All @@ -120,7 +125,7 @@ mod walkthrough {
}
// checked_from_decimal_to_value
{
let result = Price::checked_from_decimal_to_value(Price::max_instance()).unwrap();
let result = Price::checked_from_decimal_to_value(Price::max_instance()).unwrap();
assert_eq!(result, U256::from(Price::max_value()));
}
// checked_big_div_by_number & checked_big_div_by_number_up
Expand Down

0 comments on commit febdad9

Please sign in to comment.