about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2021-03-21 20:22:26 +0100
committerMara Bos <m-ou.se@m-ou.se>2021-03-21 20:22:26 +0100
commit96783625a0a2906d70690a5d76f83b1ccc028434 (patch)
tree84ddcf2e789415d3d86c17f5ea5b5950578320bf /library/std/src
parent2da9856f171f909dd072bd59d190a036dc13fc38 (diff)
downloadrust-96783625a0a2906d70690a5d76f83b1ccc028434.tar.gz
rust-96783625a0a2906d70690a5d76f83b1ccc028434.zip
Add test for io::Error::new_const.
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/io/error/tests.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/library/std/src/io/error/tests.rs b/library/std/src/io/error/tests.rs
index eb051c33f09..5098a46313d 100644
--- a/library/std/src/io/error/tests.rs
+++ b/library/std/src/io/error/tests.rs
@@ -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"));
+}