We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a2bae3b commit 4d31b14Copy full SHA for 4d31b14
units/src/amount/tests.rs
@@ -52,8 +52,14 @@ fn sanity_check() {
52
53
#[test]
54
fn check_if_num_is_too_precise() {
55
- assert_eq!(is_too_precise("1234", 3).unwrap(), 3);
56
- assert_eq!(is_too_precise("1234.1234", 3).unwrap(), 3);
+ // Has decimal, not too precise
+ assert_eq!(is_too_precise("1234.5678", 4), Some(0));
57
+ // Has decimal, is too precise
58
+ assert_eq!(is_too_precise("1234.5678", 3), Some(3));
59
+ // No decimal, not too precise
60
+ assert_eq!(is_too_precise("1234", 4), Some(0));
61
+ // No decimal, is too precise
62
+ assert_eq!(is_too_precise("1234", 2), Some(3));
63
}
64
65
0 commit comments