Skip to content

Commit 3ba7f27

Browse files
committed
Improve decimal{,256}_implements_debug test code
1 parent bfb15c6 commit 3ba7f27

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/std/src/math/decimal.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,11 +2024,14 @@ mod tests {
20242024

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

2030+
let test_cases = ["5", "5.01", "42", "0", "2"];
20292031
for s in test_cases {
20302032
let decimal = Decimal::from_str(s).unwrap();
2031-
assert_eq!(format!("Decimal({})", s), format!("{:?}", decimal));
2033+
let expected = format!("Decimal({})", s);
2034+
assert_eq!(format!("{:?}", decimal), expected);
20322035
}
20332036
}
20342037
}

packages/std/src/math/decimal256.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2171,11 +2171,14 @@ mod tests {
21712171

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

2177+
let test_cases = ["5", "5.01", "42", "0", "2"];
21762178
for s in test_cases {
21772179
let decimal256 = Decimal256::from_str(s).unwrap();
2178-
assert_eq!(format!("Decimal256({})", s), format!("{:?}", decimal256));
2180+
let expected = format!("Decimal256({})", s);
2181+
assert_eq!(format!("{:?}", decimal256), expected);
21792182
}
21802183
}
21812184
}

0 commit comments

Comments
 (0)