test case

This commit is contained in:
Ali MJ Al-Nasrawy 2021-06-03 15:35:09 +03:00
parent a1bf8662c9
commit 34b58f415a
1 changed files with 10 additions and 0 deletions

View File

@ -259,6 +259,16 @@ mod tests {
assert_eq!(path.get("id").unwrap(), &test); assert_eq!(path.get("id").unwrap(), &test);
} }
#[test]
fn test_invalid_utf8() {
let invalid_utf8 = percent_encode((0x80..=0xff).collect::<Vec<_>>().as_slice());
let uri = Uri::try_from(format!("/{}", invalid_utf8)).unwrap();
let path = Path::new(Url::new(uri));
// We should always get a valid utf8 string
assert!(String::from_utf8(path.path().as_bytes().to_owned()).is_ok());
}
#[test] #[test]
fn test_from_hex() { fn test_from_hex() {
let hex = b"0123456789abcdefABCDEF"; let hex = b"0123456789abcdefABCDEF";