Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/amount_precision.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! ISO 20022 allows an amount 18 significant digits. f64 carries 15.

use mx_message::document::camt_053_001_08::ActiveOrHistoricCurrencyAndAmount;

#[test]
fn an_eighteen_digit_amount_is_not_rounded() {
let xml = r#"<Amt Ccy="KZT">123456789012345678</Amt>"#;
let amt: ActiveOrHistoricCurrencyAndAmount =
quick_xml::de::from_str(xml).expect("the amount parses");

// Nothing here is exotic: 18 digits is what the standard permits, and the
// nearest f64 to this one is 123456789012345680.
assert_eq!(amt.value.to_string(), "123456789012345678");
}