File tree Expand file tree Collapse file tree 2 files changed +25
-8
lines changed Expand file tree Collapse file tree 2 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -170,10 +170,10 @@ pub enum ServerError {
170170 Overflow ,
171171 /// Server maximum capacity has been reached.
172172 ServerFull ,
173- /// Underflow occurred while processing messages.
174- Underflow ,
175173 /// Shutdown requested.
176174 ShutdownEvent ,
175+ /// Underflow occurred while processing messages.
176+ Underflow ,
177177}
178178
179179impl Display for ServerError {
@@ -348,6 +348,23 @@ mod tests {
348348 }
349349 }
350350
351+ impl PartialEq for ServerError {
352+ fn eq ( & self , other : & Self ) -> bool {
353+ use self :: ServerError :: * ;
354+ match ( self , other) {
355+ ( ConnectionError ( ref e) , ConnectionError ( ref other_e) ) => e. eq ( other_e) ,
356+ ( IOError ( ref e) , IOError ( ref other_e) ) => {
357+ e. raw_os_error ( ) == other_e. raw_os_error ( )
358+ }
359+ ( Overflow , Overflow ) => true ,
360+ ( ServerFull , ServerFull ) => true ,
361+ ( ShutdownEvent , ShutdownEvent ) => true ,
362+ ( Underflow , Underflow ) => true ,
363+ _ => false ,
364+ }
365+ }
366+ }
367+
351368 #[ test]
352369 fn test_version ( ) {
353370 // Tests for raw()
Original file line number Diff line number Diff line change @@ -1151,11 +1151,11 @@ mod tests {
11511151 handler. join ( ) . unwrap ( ) ;
11521152
11531153 // Expect shutdown event instead of http request event.
1154- match & * request_result. lock ( ) . unwrap ( ) {
1155- Err ( ServerError :: ShutdownEvent ) => ( ) ,
1156- v => {
1157- panic ! ( "Expected shutdown event, instead got {:?}." , v )
1158- }
1159- } ;
1154+ let res = request_result. lock ( ) . unwrap ( ) ;
1155+ assert_eq ! (
1156+ res . as_ref ( ) . unwrap_err ( ) ,
1157+ & ServerError :: ShutdownEvent ,
1158+ "Expected shutdown event, instead got {res:?}"
1159+ ) ;
11601160 }
11611161}
You can’t perform that action at this time.
0 commit comments