Skip to content
Myr

Increase error test coverage.

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

error.rs coverage: Lines: 84.26% -> 91.88% Functions: 37.1% -> 39.07% Total coverage: Lines: 83.55% -> 87.5% Functions: 45.21% -> 46.42%

authored by Bram Bonné · committed by Bram Bonné · parent b4f670d · 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
155 unmodified lines
156157 drop(err);158 assert!(dropped.all());159}160161#[test]162fn test_root_cause() {163 let (err, _) = make_chain();164165 assert_eq!(err.root_cause().to_string(), "no such file or directory");166}
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 = AsRef::<dyn StdError>::as_ref(&error);91 assert_eq!("oh no!", ref_dyn.to_string());92 let ref_dyn_send_sync = AsRef::<dyn StdError + Send + Sync>::as_ref(&error);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