Add test for io::Error::new_const.

This commit is contained in:
Mara Bos 2021-03-21 20:22:26 +01:00
parent 2da9856f17
commit 96783625a0

View File

@ -57,3 +57,13 @@ impl error::Error for TestError {}
let extracted = err.into_inner().unwrap();
extracted.downcast::<TestError>().unwrap();
}
#[test]
fn test_const() {
const E: Error = Error::new_const(ErrorKind::NotFound, &"hello");
assert_eq!(E.kind(), ErrorKind::NotFound);
assert_eq!(E.to_string(), "hello");
assert!(format!("{:?}", E).contains("\"hello\""));
assert!(format!("{:?}", E).contains("NotFound"));
}