Skip to content
Myr

Merge pull request 159 from BramBonne/error-coverage

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 · parents 6632b23, 02f10bf · Browse files · 3 files+36 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

3 files+36 added−0 removed

  • tests:+36 added−0 removed

3 files+36 added−0 removed

modified:tests/test_context.rs+7 added
160 unmodified lines
161162 drop(err);163 assert!(dropped.all());164}165166#[test]167fn test_root_cause() {168 let (err, _) = make_chain();169170 assert_eq!(err.root_cause().to_string(), "no such file or directory");171}
modified:tests/test_convert.rs+20 added
8 unmodified lines
9#[test]10fn test_convert() {11 let has_dropped = Flag::new();12 let error = Error::new(DetectDrop::new(&has_dropped));13 let box_dyn = Box::<dyn StdError>::from(error);14 assert_eq!("oh no!", box_dyn.to_string());15 drop(box_dyn);16 assert!(has_dropped.get());17}1819#[test]20fn test_convert_send() {21 let has_dropped = Flag::new();22 let error = Error::new(DetectDrop::new(&has_dropped));23 let box_dyn = Box::<dyn StdError + Send>::from(error);24 assert_eq!("oh no!", box_dyn.to_string());25 drop(box_dyn);26 assert!(has_dropped.get());27}2829#[test]30fn test_convert_send_sync() {31 let has_dropped = Flag::new();32 let error = Error::new(DetectDrop::new(&has_dropped));33 let box_dyn = Box::<dyn StdError + Send + Sync>::from(error);34 assert_eq!("oh no!", box_dyn.to_string());35 drop(box_dyn);36 assert!(has_dropped.get());
10 unmodified lines
modified:tests/test_downcast.rs+9 added
83 unmodified lines
84 assert!(has_dropped.get());85}8687#[test]88fn test_as_ref() {89 let error = bail_error().unwrap_err();90 let ref_dyn: &dyn StdError = error.as_ref();91 assert_eq!("oh no!", ref_dyn.to_string());92 let ref_dyn_send_sync: &(dyn StdError + Send + Sync) = error.as_ref();93 assert_eq!("oh no!", ref_dyn_send_sync.to_string());94}9596#[test]97fn test_large_alignment() {98 #[repr(align(64))]99 #[derive(Debug)]100 struct LargeAlignedError(&'static str);
23 unmodified lines