Fix test: lazy_file_with_file
This commit is contained in:
parent
9d0afade98
commit
927205dfcc
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue