Skip to content

Commit

Permalink
Improve decimal{,256}_implements_debug test code
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Jan 26, 2023
1 parent bfb15c6 commit 3ba7f27
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions packages/std/src/math/decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2024,11 +2024,14 @@ mod tests {

#[test]
fn decimal_implements_debug() {
let test_cases = ["5", "5.01", "42", "0", "2"];
let decimal = Decimal::from_str("123.45").unwrap();
assert_eq!(format!("{:?}", decimal), "Decimal(123.45)");

let test_cases = ["5", "5.01", "42", "0", "2"];
for s in test_cases {
let decimal = Decimal::from_str(s).unwrap();
assert_eq!(format!("Decimal({})", s), format!("{:?}", decimal));
let expected = format!("Decimal({})", s);
assert_eq!(format!("{:?}", decimal), expected);
}
}
}
7 changes: 5 additions & 2 deletions packages/std/src/math/decimal256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2171,11 +2171,14 @@ mod tests {

#[test]
fn decimal256_implements_debug() {
let test_cases = ["5", "5.01", "42", "0", "2"];
let decimal = Decimal256::from_str("123.45").unwrap();
assert_eq!(format!("{:?}", decimal), "Decimal256(123.45)");

let test_cases = ["5", "5.01", "42", "0", "2"];
for s in test_cases {
let decimal256 = Decimal256::from_str(s).unwrap();
assert_eq!(format!("Decimal256({})", s), format!("{:?}", decimal256));
let expected = format!("Decimal256({})", s);
assert_eq!(format!("{:?}", decimal256), expected);
}
}
}

0 comments on commit 3ba7f27

Please sign in to comment.