1use super::EncodingError; 2 3#[test] 4fn test_invalid() { 5 use EncodingError::Byte; 6 use EncodingError::CodePoint; 7 use EncodingError::End; 8 9 #[track_caller] 10 fn test(error: EncodingError, string: &[u8]) { 11 assert_eq!(Err(error), super::from_bytes(string)); 12 } 13 14 test(Byte(b'\x83'), b"\x0C\x83\xD7\x3E"); 15 test(Byte(b'\x52'), b"\x19\xF7\x52\x84"); 16 test(Byte(b'\xB8'), b"\x70\xB8\x1F\x66"); 17 test(CodePoint(0x34_0388), b"\x70\xFD\x80\x8E\x88"); 18 test(Byte(b'\x80'), b"\x80"); 19 test(Byte(b'\x80'), b"\x80\x80"); 20 test(Byte(b'\x80'), b"\x80\x80\x80"); 21 test(Byte(b'\x81'), b"\x81"); 22 test(Byte(b'\x88'), b"\x88\xB4\xC7\x46"); 23 test(Byte(b'\x97'), b"\x97\xCE\x06"); 24 test(Byte(b'\x00'), b"\xC2\x00"); 25 test(Byte(b'\x7F'), b"\xC2\x7F"); 26 test(Byte(b'\x09'), b"\xCD\x09\x95"); 27 test(Byte(b'\x43'), b"\xCD\x43\x5F\xA0"); 28 test(Byte(b'\x69'), b"\xD7\x69\xB2"); 29 test(CodePoint(0x528), b"\xE0\x94\xA8"); 30 test(CodePoint(0x766), b"\xE0\x9D\xA6\x12\xAE"); 31 test(Byte(b'\xFD'), b"\xE2\xAB\xFD\x51"); 32 test(Byte(b'\xC4'), b"\xE3\xC4"); 33 test(CodePoint(0xDC00), b"\xED\xA0\x80\xED\xB0\x80"); 34 test(End(), b"\xF1"); 35 test(End(), b"\xF1\x80"); 36 test(End(), b"\xF1\x80\x80"); 37 test(Byte(b'\xF1'), b"\xF1\x80\x80\xF1"); 38 test(CodePoint(0x11_09CC), b"\xF4\x90\xA7\x8C"); 39 test(CodePoint(0x15_EC46), b"\xF5\x9E\xB1\x86"); 40 test(End(), b"\xFB"); 41 test(End(), b"\xFB\x80"); 42 test(End(), b"\xFB\x80\x80"); 43 test(CodePoint(0x2C_0000), b"\xFB\x80\x80\x80"); 44 test(End(), b"\xFF"); 45 test(End(), b"\xFF\x80"); 46 test(End(), b"\xFF\x80\x80"); 47 test(CodePoint(0x3C_0000), b"\xFF\x80\x80\x80"); 48 test(CodePoint(0x3C_6143), b"\xFF\x86\x85\x83"); 49} 50