From 12732d929809b871fd5102bfed6a7f5ec2e4b800 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 23 Mar 2025 18:24:12 -0700 Subject: [PATCH] test non-ascii custom currency --- rust/pspp/src/format/mod.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/rust/pspp/src/format/mod.rs b/rust/pspp/src/format/mod.rs index c49d4a2226..d444a8c4e8 100644 --- a/rust/pspp/src/format/mod.rs +++ b/rust/pspp/src/format/mod.rs @@ -2154,4 +2154,26 @@ mod test { test.test(-0.99, [" -.99", " -1.0"], ["-0.99", " -1.0"]); test.test(-0.01, [" -.01", " .0"], ["-0.01", " 0.0"]); } + + #[test] + fn non_ascii_cc() { + fn test(settings: &Settings, value: f64, expected: &str) { + assert_eq!( + &Value::from(value) + .display(Format::new(Type::CC(CC::A), 10, 2).unwrap(), UTF_8) + .with_settings(settings) + .to_string(), + expected + ); + } + + let settings = Settings::default().with_cc(CC::A, "«,¥,€,»".parse().unwrap()); + test(&settings, 1.0, " ¥1.00€ "); + test(&settings, -1.0, " «¥1.00€»"); + test(&settings, 1.5, " ¥1.50€ "); + test(&settings, -1.5, " «¥1.50€»"); + test(&settings, 0.75, " ¥.75€ "); + test(&settings, 1.5e10, " ¥2E+010€ "); + test(&settings, -1.5e10, "«¥2E+010€»"); + } } -- 2.30.2