File tree 2 files changed +25
-8
lines changed
2 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -170,10 +170,10 @@ pub enum ServerError {
170
170
Overflow ,
171
171
/// Server maximum capacity has been reached.
172
172
ServerFull ,
173
- /// Underflow occurred while processing messages.
174
- Underflow ,
175
173
/// Shutdown requested.
176
174
ShutdownEvent ,
175
+ /// Underflow occurred while processing messages.
176
+ Underflow ,
177
177
}
178
178
179
179
impl Display for ServerError {
@@ -348,6 +348,23 @@ mod tests {
348
348
}
349
349
}
350
350
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
+
351
368
#[ test]
352
369
fn test_version ( ) {
353
370
// Tests for raw()
Original file line number Diff line number Diff line change @@ -1151,11 +1151,11 @@ mod tests {
1151
1151
handler. join ( ) . unwrap ( ) ;
1152
1152
1153
1153
// 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
+ ) ;
1160
1160
}
1161
1161
}
You can’t perform that action at this time.
0 commit comments