| 1 | use std::collections::HashMap; |
| 2 | use {FmtError, Format}; |
| 3 | |
| 4 | /// cautione here, this test just checks if the old float formatting behaviour is still present, |
| 5 | /// as this was changed in 0.2.0 |
| 6 | #[test] |
| 7 | #[allow(deprecated)] |
| 8 | fn test_legacy() -> Result<(), FmtError> { |
| 9 | let mut vars: HashMap<String, f64> = HashMap::new(); |
| 10 | vars.insert("Zero".to_string(), 0.0); |
| 11 | vars.insert("One".to_string(), 10.0 / 3.0); |
| 12 | vars.insert("Two".to_string(), 2.0); |
| 13 | |
| 14 | assert_eq!("0".to_string(), "{Zero}".format_display(&vars)?); |
| 15 | assert_eq!("0".to_string(), "{Zero:.2}".format_display(&vars)?); |
| 16 | assert_eq!("3.333".to_string(), "{One:.5}".format_display(&vars)?); |
| 17 | assert_eq!("2".to_string(), "{Two}".format_display(&vars)?); |
| 18 | assert_eq!("0 ".to_string(), "{Zero:<5.2}".format_display(&vars)?); |
| 19 | |
| 20 | Ok(()) |
| 21 | } |