Fix test: lazy_file_with_file

This commit is contained in:
Matthias Beyer 2016-01-18 18:30:55 +01:00
parent 9d0afade98
commit 927205dfcc
1 changed files with 16 additions and 7 deletions

View File

@ -105,14 +105,23 @@ mod test {
let dir = get_dir(); let dir = get_dir();
let mut path = PathBuf::from(dir.path()); let mut path = PathBuf::from(dir.path());
path.set_file_name("test2"); path.set_file_name("test2");
let mut lf = LazyFile::new(path);
let mut file = lf.create_file().unwrap();
file.write(b"Hello World").unwrap(); {
file.sync_all().unwrap(); let mut lf = LazyFile::new(path.clone());
let mut s = Vec::new(); let mut file = lf.create_file().unwrap();
file.read_to_end(&mut s).unwrap();
assert_eq!(s, "Hello World".to_string().into_bytes()); file.write(b"Hello World").unwrap();
file.sync_all().unwrap();
}
{
let mut lf = LazyFile::new(path);
let mut file = lf.create_file().unwrap();
let mut s = Vec::new();
file.read_to_end(&mut s).unwrap();
assert_eq!(s, "Hello World".to_string().into_bytes());
}
dir.close().unwrap(); dir.close().unwrap();
} }