| 1 | #[test] |
| 2 | fn roundtrip_implicit_some_stack() { |
| 3 | check_roundtrip(Option::<()>::None, "None"); |
| 4 | check_roundtrip(Some(()), "()"); |
| 5 | check_roundtrip(Some(Some(())), "()"); |
| 6 | check_roundtrip(Some(Some(Some(()))), "()"); |
| 7 | check_roundtrip(Some(Option::<()>::None), "Some(None)"); |
| 8 | check_roundtrip(Some(Some(Option::<()>::None)), "Some(Some(None))"); |
| 9 | } |
| 10 | |
| 11 | fn check_roundtrip< |
| 12 | T: PartialEq + core::fmt::Debug + serde::Serialize + serde::de::DeserializeOwned, |
| 13 | >( |
| 14 | val: T, |
| 15 | check: &str, |
| 16 | ) { |
| 17 | let options = |
| 18 | ron::Options::default().with_default_extension(ron::extensions::Extensions::IMPLICIT_SOME); |
| 19 | |
| 20 | let ron = options.to_string(&val).unwrap(); |
| 21 | assert_eq!(ron, check); |
| 22 | |
| 23 | let de: T = options.from_str(&ron).unwrap(); |
| 24 | assert_eq!(de, val); |
| 25 | } |