| 1 | use superrust-analyzer cargo strfmt 0.2.4 tests/::superrust-analyzer cargo strfmt 0.2.4 crate/::formatterrust-analyzer cargo strfmt 0.2.4 formatter/::Formatterrust-analyzer cargo strfmt 0.2.4 formatter/Formatter#; |
| 2 | use superrust-analyzer cargo strfmt 0.2.4 tests/::superrust-analyzer cargo strfmt 0.2.4 crate/::typesrust-analyzer cargo strfmt 0.2.4 types/::*; |
| 3 | |
| 4 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 5 | fn test_fmt_from_strrust-analyzer cargo strfmt 0.2.4 tests/fmt/test_fmt_from_str().() { |
| 6 | let s = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(); |
| 7 | { |
| 8 | let mut s = s.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().(); |
| 9 | let f = Formatterrust-analyzer cargo strfmt 0.2.4 formatter/Formatter#::from_strrust-analyzer cargo strfmt 0.2.4 formatter/impl#[`Formatter<'a, 'b>`]from_str().("x:<.3", &mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 10 | // defaults |
| 11 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(f.fillrust-analyzer cargo strfmt 0.2.4 formatter/impl#[`Formatter<'a, 'b>`]fill().(), ' '); |
| 12 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(f.signrust-analyzer cargo strfmt 0.2.4 formatter/impl#[`Formatter<'a, 'b>`]sign().(), Signrust-analyzer cargo strfmt 0.2.4 types/Sign#::Unspecifiedrust-analyzer cargo strfmt 0.2.4 types/Sign#Unspecified#); |
| 13 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(f.alternaterust-analyzer cargo strfmt 0.2.4 formatter/impl#[`Formatter<'a, 'b>`]alternate().(), false); |
| 14 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(f.widthrust-analyzer cargo strfmt 0.2.4 formatter/impl#[`Formatter<'a, 'b>`]width().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 15 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(f.thousandsrust-analyzer cargo strfmt 0.2.4 formatter/impl#[`Formatter<'a, 'b>`]thousands().(), false); |
| 16 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(f.tyrust-analyzer cargo strfmt 0.2.4 formatter/impl#[`Formatter<'a, 'b>`]ty().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 17 | |
| 18 | // specified |
| 19 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(f.keyrust-analyzer cargo strfmt 0.2.4 formatter/Formatter#key., "x"); |
| 20 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(f.precisionrust-analyzer cargo strfmt 0.2.4 formatter/impl#[`Formatter<'a, 'b>`]precision().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), 3); |
| 21 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(f.alignrust-analyzer cargo strfmt 0.2.4 formatter/impl#[`Formatter<'a, 'b>`]align().(), Alignmentrust-analyzer cargo strfmt 0.2.4 types/Alignment#::Leftrust-analyzer cargo strfmt 0.2.4 types/Alignment#Left#); |
| 22 | } |
| 23 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(Formatterrust-analyzer cargo strfmt 0.2.4 formatter/Formatter#::from_strrust-analyzer cargo strfmt 0.2.4 formatter/impl#[`Formatter<'a, 'b>`]from_str().("x:^.3", &mut s.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().()).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 24 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(Formatterrust-analyzer cargo strfmt 0.2.4 formatter/Formatter#::from_strrust-analyzer cargo strfmt 0.2.4 formatter/impl#[`Formatter<'a, 'b>`]from_str().("xxx: <88.3", &mut s.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().()).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 25 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(Formatterrust-analyzer cargo strfmt 0.2.4 formatter/Formatter#::from_strrust-analyzer cargo strfmt 0.2.4 formatter/impl#[`Formatter<'a, 'b>`]from_str().("xxx: <88.3", &mut s.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().()).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 26 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(Formatterrust-analyzer cargo strfmt 0.2.4 formatter/Formatter#::from_strrust-analyzer cargo strfmt 0.2.4 formatter/impl#[`Formatter<'a, 'b>`]from_str().("xxx:a34", &mut s.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().()).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 27 | } |