1
#[test]
2
4
fn roundtrip_implicit_some_stack() {
3
4
    check_roundtrip(Option::<()>::None, "None");
4
4
    check_roundtrip(Some(()), "()");
5
4
    check_roundtrip(Some(Some(())), "()");
6
4
    check_roundtrip(Some(Some(Some(()))), "()");
7
4
    check_roundtrip(Some(Option::<()>::None), "Some(None)");
8
4
    check_roundtrip(Some(Some(Option::<()>::None)), "Some(Some(None))");
9
4
}
10

            
11
24
fn check_roundtrip<
12
24
    T: PartialEq + std::fmt::Debug + serde::Serialize + serde::de::DeserializeOwned,
13
24
>(
14
24
    val: T,
15
24
    check: &str,
16
24
) {
17
24
    let options =
18
24
        ron::Options::default().with_default_extension(ron::extensions::Extensions::IMPLICIT_SOME);
19
24

            
20
24
    let ron = options.to_string(&val).unwrap();
21
24
    assert_eq!(ron, check);
22

            
23
24
    let de: T = options.from_str(&ron).unwrap();
24
24
    assert_eq!(de, val);
25
24
}