Skip to content

Commit 9678362

Browse files
committed
Add test for io::Error::new_const.
1 parent 2da9856 commit 9678362

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

library/std/src/io/error/tests.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,13 @@ fn test_downcasting() {
5757
let extracted = err.into_inner().unwrap();
5858
extracted.downcast::<TestError>().unwrap();
5959
}
60+
61+
#[test]
62+
fn test_const() {
63+
const E: Error = Error::new_const(ErrorKind::NotFound, &"hello");
64+
65+
assert_eq!(E.kind(), ErrorKind::NotFound);
66+
assert_eq!(E.to_string(), "hello");
67+
assert!(format!("{:?}", E).contains("\"hello\""));
68+
assert!(format!("{:?}", E).contains("NotFound"));
69+
}

0 commit comments

Comments
 (0)