Improve is_too_precise test

Two of the match arms in `is_too_precise` were untested.

Expand the existing test to check all 4 cases.
This commit is contained in:
Jamil Lambert, PhD 2025-07-02 13:29:00 +01:00
parent a2bae3bb0b
commit 4d31b141a8
No known key found for this signature in database
GPG Key ID: 54DC29234AB5D2C0
1 changed files with 8 additions and 2 deletions

View File

@ -52,8 +52,14 @@ fn sanity_check() {
#[test]
fn check_if_num_is_too_precise() {
assert_eq!(is_too_precise("1234", 3).unwrap(), 3);
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));
// Has decimal, is too precise
assert_eq!(is_too_precise("1234.5678", 3), Some(3));
// No decimal, not too precise
assert_eq!(is_too_precise("1234", 4), Some(0));
// No decimal, is too precise
assert_eq!(is_too_precise("1234", 2), Some(3));
}
#[test]