From febdad971165c3a53d2ced6c9cbb1438ad3d7c2a Mon Sep 17 00:00:00 2001 From: Wojciech Date: Wed, 11 Oct 2023 14:46:18 +0200 Subject: [PATCH] Testing checked_div in walkthrough --- src/walkthrough.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/walkthrough.rs b/src/walkthrough.rs index e75a165..817b331 100644 --- a/src/walkthrough.rs +++ b/src/walkthrough.rs @@ -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 = @@ -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() @@ -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