File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -394,19 +394,25 @@ mod tests {
394
394
assert_eq ! ( c_string. to_str( ) , Ok ( "hello" ) ) ;
395
395
396
396
// Call must fail since `w\0rld` contains an interior nul byte.
397
- assert ! ( c_string. extend_from_bytes( b"w\0 rld" ) . is_err( ) ) ;
397
+ assert ! ( matches!(
398
+ c_string. extend_from_bytes( b"w\0 rld" ) ,
399
+ Err ( ExtendError :: InteriorNulByte ( 1 ) )
400
+ ) ) ;
398
401
399
402
// However, the call above _must not_ have invalidated the state of our CString
400
403
assert_eq ! ( c_string. to_str( ) , Ok ( "hello" ) ) ;
401
404
402
405
// Call must fail since we can't store "hello world\0" in 11 bytes
403
- assert ! ( c_string. extend_from_bytes( b" world" ) . is_err( ) ) ;
406
+ assert ! ( matches!(
407
+ c_string. extend_from_bytes( b" world" ) ,
408
+ Err ( ExtendError :: Capacity ( CapacityError ) )
409
+ ) ) ;
404
410
405
411
// Yet again, the call above must not have invalidated the state of our CString
406
412
// (as it would e.g. if we pushed the bytes but then failed to push the nul terminator)
407
413
assert_eq ! ( c_string. to_str( ) , Ok ( "hello" ) ) ;
408
414
409
- assert ! ( c_string. extend_from_bytes( b" Bill" ) . is_ok ( ) ) ;
415
+ c_string. extend_from_bytes ( b" Bill" ) . unwrap ( ) ;
410
416
411
417
assert_eq ! ( c_string. to_str( ) , Ok ( "hello Bill" ) ) ;
412
418
}
You can’t perform that action at this time.
0 commit comments