File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -162,3 +162,10 @@ fn test_unsuccessful_downcast() {
162
162
drop ( err) ;
163
163
assert ! ( dropped. all( ) ) ;
164
164
}
165
+
166
+ #[ test]
167
+ fn test_root_cause ( ) {
168
+ let ( err, _) = make_chain ( ) ;
169
+
170
+ assert_eq ! ( err. root_cause( ) . to_string( ) , "no such file or directory" ) ;
171
+ }
Original file line number Diff line number Diff line change @@ -8,6 +8,26 @@ use std::error::Error as StdError;
8
8
9
9
#[ test]
10
10
fn 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
+ }
18
+
19
+ #[ test]
20
+ fn 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
+ }
28
+
29
+ #[ test]
30
+ fn test_convert_send_sync ( ) {
11
31
let has_dropped = Flag :: new ( ) ;
12
32
let error = Error :: new ( DetectDrop :: new ( & has_dropped) ) ;
13
33
let box_dyn = Box :: < dyn StdError + Send + Sync > :: from ( error) ;
Original file line number Diff line number Diff line change @@ -84,6 +84,15 @@ fn test_drop() {
84
84
assert ! ( has_dropped. get( ) ) ;
85
85
}
86
86
87
+ #[ test]
88
+ fn 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
+ }
95
+
87
96
#[ test]
88
97
fn test_large_alignment ( ) {
89
98
#[ repr( align( 64 ) ) ]
You can’t perform that action at this time.
0 commit comments