| 1 |
#[test] |
| 2 |
fn test_deserialise_byte_slice() { |
| 3 |
let val: &[u8] = &[0_u8, 1_u8, 2_u8, 3_u8]; |
| 4 |
let ron = ron::to_string(val).unwrap(); |
| 5 |
assert_eq!(ron, "[0,1,2,3]"); |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
assert_eq!( |
| 13 |
ron::from_str::<&[u8]>(&ron), |
| 14 |
Err(ron::error::SpannedError { |
| 15 |
code: ron::error::Error::InvalidValueForType { |
| 16 |
expected: String::from("a borrowed byte array"), |
| 17 |
found: String::from("the byte string b\"\\x00\\x01\\x02\\x03\""), |
| 18 |
}, |
| 19 |
span: ron::error::Span { |
| 20 |
start: ron::error::Position { line: 1, col: 9 }, |
| 21 |
end: ron::error::Position { line: 1, col: 10 }, |
| 22 |
} |
| 23 |
}) |
| 24 |
); |
| 25 |
} |