Skip to content

Commit

Permalink
Add test for io::Error::new_const.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed Mar 21, 2021
1 parent 2da9856 commit 9678362
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions library/std/src/io/error/tests.rs
Expand Up @@ -57,3 +57,13 @@ fn test_downcasting() {
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"));
}

0 comments on commit 9678362

Please sign in to comment.