| 891 | |
| 892 | #[test] |
| 893 | fn test_parse_key() { |
| 894 | let expected = Ok(CFormatSpecKeyed { |
| 895 | mapping_key: Some("amount".to_owned()), |
| 896 | spec: CFormatSpec { |
| 897 | format_type: CFormatType::Number(CNumberType::DecimalD), |
| 898 | min_field_width: None, |
| 899 | precision: None, |
| 900 | flags: CConversionFlags::empty(), |
| 901 | }, |
| 902 | }); |
| 903 | assert_eq!("%(amount)d".parse::<CFormatSpecKeyed<String>>(), expected); |
| 904 | |
| 905 | let expected = Ok(CFormatSpecKeyed { |
| 906 | mapping_key: Some("m((u(((l((((ti))))p)))l))e".to_owned()), |
| 907 | spec: CFormatSpec { |
| 908 | format_type: CFormatType::Number(CNumberType::DecimalD), |
| 909 | min_field_width: None, |
| 910 | precision: None, |
| 911 | flags: CConversionFlags::empty(), |
| 912 | }, |
| 913 | }); |
| 914 | assert_eq!( |
| 915 | "%(m((u(((l((((ti))))p)))l))e)d".parse::<CFormatSpecKeyed<String>>(), |
| 916 | expected |
| 917 | ); |
| 918 | } |
| 919 | |
| 920 | #[test] |
| 921 | fn test_format_parse_key_fail() { |