@@ -321,7 +321,8 @@ mod tests {
321
321
use crate :: io:: read;
322
322
use core:: mem:: MaybeUninit ;
323
323
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 ( ) ;
325
326
326
327
let mut buf = vec ! [ 0_u8 ; 3 ] ;
327
328
buf. reserve ( 32 ) ;
@@ -360,12 +361,14 @@ mod tests {
360
361
use crate :: io:: read;
361
362
use std:: io:: { Seek , SeekFrom } ;
362
363
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 ( ) ;
364
367
365
368
let mut buf = [ 0_u8 ; 64 ] ;
366
369
let nread = read ( & input, & mut buf) . unwrap ( ) ;
367
370
assert_eq ! ( nread, buf. len( ) ) ;
368
- assert_eq ! ( & buf[ ..9 ] , b"[package] " ) ;
371
+ assert_eq ! ( & buf[ ..38 ] , b"//! Utilities to help with buffering. \n " ) ;
369
372
input. seek ( SeekFrom :: End ( -1 ) ) . unwrap ( ) ;
370
373
let nread = read ( & input, & mut buf) . unwrap ( ) ;
371
374
assert_eq ! ( nread, 1 ) ;
@@ -381,16 +384,18 @@ mod tests {
381
384
use core:: mem:: MaybeUninit ;
382
385
use std:: io:: { Seek , SeekFrom } ;
383
386
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 ( ) ;
385
390
386
391
let mut buf = [ MaybeUninit :: < u8 > :: uninit ( ) ; 64 ] ;
387
392
let ( init, uninit) = read ( & input, & mut buf) . unwrap ( ) ;
388
393
assert_eq ! ( uninit. len( ) , 0 ) ;
389
- assert_eq ! ( & init[ ..9 ] , b"[package] " ) ;
394
+ assert_eq ! ( & init[ ..38 ] , b"//! Utilities to help with buffering. \n " ) ;
390
395
assert_eq ! ( init. len( ) , buf. len( ) ) ;
391
396
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 "
394
399
) ;
395
400
input. seek ( SeekFrom :: End ( -1 ) ) . unwrap ( ) ;
396
401
let ( init, uninit) = read ( & input, & mut buf) . unwrap ( ) ;
@@ -408,13 +413,15 @@ mod tests {
408
413
use crate :: io:: read;
409
414
use std:: io:: { Seek , SeekFrom } ;
410
415
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 ( ) ;
412
419
413
420
let mut buf = Vec :: with_capacity ( 64 ) ;
414
421
let nread = read ( & input, spare_capacity ( & mut buf) ) . unwrap ( ) ;
415
422
assert_eq ! ( nread, buf. capacity( ) ) ;
416
423
assert_eq ! ( nread, buf. len( ) ) ;
417
- assert_eq ! ( & buf[ ..9 ] , b"[package] " ) ;
424
+ assert_eq ! ( & buf[ ..38 ] , b"//! Utilities to help with buffering. \n " ) ;
418
425
buf. clear ( ) ;
419
426
input. seek ( SeekFrom :: End ( -1 ) ) . unwrap ( ) ;
420
427
let nread = read ( & input, spare_capacity ( & mut buf) ) . unwrap ( ) ;
0 commit comments