@@ -321,7 +321,8 @@ mod tests {
321321 use crate :: io:: read;
322322 use core:: mem:: MaybeUninit ;
323323
324- let input = std:: fs:: File :: open ( "Cargo.toml" ) . unwrap ( ) ;
324+ // We need to obtain input stream, so open our own source file.
325+ let input = std:: fs:: File :: open ( "src/buffer.rs" ) . unwrap ( ) ;
325326
326327 let mut buf = vec ! [ 0_u8 ; 3 ] ;
327328 buf. reserve ( 32 ) ;
@@ -360,12 +361,14 @@ mod tests {
360361 use crate :: io:: read;
361362 use std:: io:: { Seek , SeekFrom } ;
362363
363- let mut input = std:: fs:: File :: open ( "Cargo.toml" ) . unwrap ( ) ;
364+ // We need to obtain input stream with contents that we can compare
365+ // against, so open our own source file.
366+ let mut input = std:: fs:: File :: open ( "src/buffer.rs" ) . unwrap ( ) ;
364367
365368 let mut buf = [ 0_u8 ; 64 ] ;
366369 let nread = read ( & input, & mut buf) . unwrap ( ) ;
367370 assert_eq ! ( nread, buf. len( ) ) ;
368- assert_eq ! ( & buf[ ..9 ] , b"[package] " ) ;
371+ assert_eq ! ( & buf[ ..38 ] , b"//! Utilities to help with buffering. \n " ) ;
369372 input. seek ( SeekFrom :: End ( -1 ) ) . unwrap ( ) ;
370373 let nread = read ( & input, & mut buf) . unwrap ( ) ;
371374 assert_eq ! ( nread, 1 ) ;
@@ -381,16 +384,18 @@ mod tests {
381384 use core:: mem:: MaybeUninit ;
382385 use std:: io:: { Seek , SeekFrom } ;
383386
384- let mut input = std:: fs:: File :: open ( "Cargo.toml" ) . unwrap ( ) ;
387+ // We need to obtain input stream with contents that we can compare
388+ // against, so open our own source file.
389+ let mut input = std:: fs:: File :: open ( "src/buffer.rs" ) . unwrap ( ) ;
385390
386391 let mut buf = [ MaybeUninit :: < u8 > :: uninit ( ) ; 64 ] ;
387392 let ( init, uninit) = read ( & input, & mut buf) . unwrap ( ) ;
388393 assert_eq ! ( uninit. len( ) , 0 ) ;
389- assert_eq ! ( & init[ ..9 ] , b"[package] " ) ;
394+ assert_eq ! ( & init[ ..38 ] , b"//! Utilities to help with buffering. \n " ) ;
390395 assert_eq ! ( init. len( ) , buf. len( ) ) ;
391396 assert_eq ! (
392- unsafe { core:: mem:: transmute:: <& mut [ MaybeUninit <u8 >] , & mut [ u8 ] >( & mut buf[ ..9 ] ) } ,
393- b"[package] "
397+ unsafe { core:: mem:: transmute:: <& mut [ MaybeUninit <u8 >] , & mut [ u8 ] >( & mut buf[ ..38 ] ) } ,
398+ b"//! Utilities to help with buffering. \n "
394399 ) ;
395400 input. seek ( SeekFrom :: End ( -1 ) ) . unwrap ( ) ;
396401 let ( init, uninit) = read ( & input, & mut buf) . unwrap ( ) ;
@@ -408,13 +413,15 @@ mod tests {
408413 use crate :: io:: read;
409414 use std:: io:: { Seek , SeekFrom } ;
410415
411- let mut input = std:: fs:: File :: open ( "Cargo.toml" ) . unwrap ( ) ;
416+ // We need to obtain input stream with contents that we can compare
417+ // against, so open our own source file.
418+ let mut input = std:: fs:: File :: open ( "src/buffer.rs" ) . unwrap ( ) ;
412419
413420 let mut buf = Vec :: with_capacity ( 64 ) ;
414421 let nread = read ( & input, spare_capacity ( & mut buf) ) . unwrap ( ) ;
415422 assert_eq ! ( nread, buf. capacity( ) ) ;
416423 assert_eq ! ( nread, buf. len( ) ) ;
417- assert_eq ! ( & buf[ ..9 ] , b"[package] " ) ;
424+ assert_eq ! ( & buf[ ..38 ] , b"//! Utilities to help with buffering. \n " ) ;
418425 buf. clear ( ) ;
419426 input. seek ( SeekFrom :: End ( -1 ) ) . unwrap ( ) ;
420427 let nread = read ( & input, spare_capacity ( & mut buf) ) . unwrap ( ) ;
0 commit comments