@@ -542,6 +542,8 @@ fn test_issue_14() {
542
542
// data is treated as invalid.
543
543
#[ test]
544
544
fn test_issue_7 ( ) {
545
+ use std:: io:: ErrorKind :: UnexpectedEof ;
546
+
545
547
let mut c = Cursor :: new ( Vec :: new ( ) ) ;
546
548
let test_arr = [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ;
547
549
let test_arr_2 = [ 2 , 4 , 8 , 16 , 32 , 64 , 128 , 127 , 126 , 125 , 124 ] ;
@@ -564,17 +566,19 @@ fn test_issue_7() {
564
566
assert ! ( r. read_packet( ) . unwrap( ) . is_none( ) ) ;
565
567
}
566
568
567
- // Non-Ogg data should return an error.
569
+ // Truncated data should return the UnexpectedEof error.
568
570
let c = Cursor :: new ( vec ! [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ) ;
569
571
{
570
572
let mut r = PacketReader :: new ( c) ;
571
- assert ! ( matches!( r. read_packet( ) , Err ( OggReadError :: NoCapturePatternFound ) ) ) ;
573
+ assert ! ( matches!( r. read_packet( ) ,
574
+ Err ( OggReadError :: ReadError ( e) ) if e. kind( ) == UnexpectedEof ) ) ;
572
575
}
573
576
574
- // Empty data is considered non-Ogg data .
577
+ // Empty data should return the UnexpectedEof error .
575
578
let c = Cursor :: new ( & [ ] ) ;
576
579
{
577
580
let mut r = PacketReader :: new ( c) ;
578
- assert ! ( matches!( r. read_packet( ) , Err ( OggReadError :: NoCapturePatternFound ) ) ) ;
581
+ assert ! ( matches!( r. read_packet( ) ,
582
+ Err ( OggReadError :: ReadError ( e) ) if e. kind( ) == UnexpectedEof ) ) ;
579
583
}
580
584
}
0 commit comments