1
#[test]
2
4
fn test_deserialise_byte_slice() {
3
4
    let val: &[u8] = &[0_u8, 1_u8, 2_u8, 3_u8];
4
4
    let ron = ron::to_string(val).unwrap();
5
4
    assert_eq!(ron, "[0,1,2,3]");
6

            
7
    // deserialising a byte slice from a byte sequence should fail
8
    //  with the error that a borrowed slice was expected but a byte
9
    //  buffer was provided
10
    // NOT with an expected string error, since the byte slice
11
    //  serialisation never serialises to a string
12
4
    assert_eq!(
13
4
        ron::from_str::<&[u8]>(&ron),
14
4
        Err(ron::error::SpannedError {
15
4
            code: ron::error::Error::InvalidValueForType {
16
4
                expected: String::from("a borrowed byte array"),
17
4
                found: String::from("the byte string b\"\\x00\\x01\\x02\\x03\""),
18
4
            },
19
4
            position: ron::error::Position { line: 1, col: 10 },
20
4
        })
21
4
    );
22
4
}