Skip to content
Myr

Add downcast_ref and downcast_mut tests

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 4d051e4 · Browse files · 1 file+40 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+40 added−0 removed

  • tests:+40 added−0 removed

1 file+40 added−0 removed

modified:tests/test_downcast.rs+40 added
20 unmodified lines
21 .unwrap()22 .to_string(),23 );24}2526#[test]27fn test_downcast_ref() {28 assert_eq!(29 "oh no!",30 *bail_literal().unwrap_err().downcast_ref::<&str>().unwrap(),31 );32 assert_eq!(33 "oh no!",34 bail_fmt().unwrap_err().downcast_ref::<String>().unwrap(),35 );36 assert_eq!(37 "oh no!",38 bail_error()39 .unwrap_err()40 .downcast_ref::<io::Error>()41 .unwrap()42 .to_string(),43 );44}4546#[test]47fn test_downcast_mut() {48 assert_eq!(49 "oh no!",50 *bail_literal().unwrap_err().downcast_mut::<&str>().unwrap(),51 );52 assert_eq!(53 "oh no!",54 bail_fmt().unwrap_err().downcast_mut::<String>().unwrap(),55 );56 assert_eq!(57 "oh no!",58 bail_error()59 .unwrap_err()60 .downcast_mut::<io::Error>()61 .unwrap()62 .to_string(),63 );64}