1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
use alloc::string::ToString;
use borsh::from_slice;
#[test]
fn test_non_ascii() {
let buf = borsh::to_vec(&[0xbf, 0xf3, 0xb3, 0x77][..]).unwrap();
assert_eq!(
from_slice::<ascii::AsciiString>(&buf)
.unwrap_err()
.to_string(),
"the byte at index 0 is not ASCII"
);
let buf = borsh::to_vec("żółw").unwrap();
assert_eq!(
from_slice::<ascii::AsciiString>(&buf)
.unwrap_err()
.to_string(),
"the byte at index 0 is not ASCII"
);
assert_eq!(
from_slice::<ascii::AsciiChar>(&[0xbf])
.unwrap_err()
.to_string(),
"not an ASCII character"
);
}
|