1
const EXPTECTED: &str = "[
2
    /*[0]*/ None,
3
    /*[1]*/ Some([]),
4
    /*[2]*/ Some([
5
        /*[0]*/ 42,
6
    ]),
7
    /*[3]*/ Some([
8
        /*[0]*/ 4,
9
        /*[1]*/ 2,
10
    ]),
11
    /*[4]*/ None,
12
]";
13

            
14
const EXPTECTED_COMPACT: &str = "[/*[0]*/ None, /*[1]*/ Some([]), /*[2]*/ Some([/*[0]*/ 42]), \
15
/*[3]*/ Some([/*[0]*/ 4, /*[1]*/ 2]), /*[4]*/ None]";
16

            
17
#[test]
18
4
fn enumerate_arrays() {
19
4
    let v: Vec<Option<Vec<u8>>> = vec![None, Some(vec![]), Some(vec![42]), Some(vec![4, 2]), None];
20
4

            
21
4
    let pretty = ron::ser::PrettyConfig::new().enumerate_arrays(true);
22
4

            
23
4
    let ser = ron::ser::to_string_pretty(&v, pretty).unwrap();
24
4

            
25
4
    assert_eq!(ser, EXPTECTED);
26

            
27
4
    let de: Vec<Option<Vec<u8>>> = ron::from_str(&ser).unwrap();
28
4

            
29
4
    assert_eq!(v, de)
30
4
}
31

            
32
#[test]
33
4
fn enumerate_compact_arrays() {
34
4
    let v: Vec<Option<Vec<u8>>> = vec![None, Some(vec![]), Some(vec![42]), Some(vec![4, 2]), None];
35
4

            
36
4
    let pretty = ron::ser::PrettyConfig::new()
37
4
        .enumerate_arrays(true)
38
4
        .compact_arrays(true);
39
4

            
40
4
    let ser = ron::ser::to_string_pretty(&v, pretty).unwrap();
41
4

            
42
4
    assert_eq!(ser, EXPTECTED_COMPACT);
43

            
44
4
    let de: Vec<Option<Vec<u8>>> = ron::from_str(&ser).unwrap();
45
4

            
46
4
    assert_eq!(v, de)
47
4
}