expand clock and fs tests a bit

This commit is contained in:
Ralf Jung
2020-03-06 14:28:34 +01:00
parent c72af45b1c
commit fefa8e5344
2 changed files with 12 additions and 2 deletions
+7 -1
View File
@@ -4,5 +4,11 @@
use std::time::SystemTime;
fn main() {
let _now = SystemTime::now();
let now1 = SystemTime::now();
// Do some work to make time pass.
for _ in 0..10 { drop(vec![42]); }
let now2 = SystemTime::now();
assert!(now2 > now1);
}
+5 -1
View File
@@ -215,9 +215,13 @@ fn test_directory() {
// Clean up the files in the directory
remove_file(&path_1).unwrap();
remove_file(&path_2).unwrap();
// Now there should be nothing left in the directory.
let dir_iter = read_dir(&dir_path).unwrap();
let file_names = dir_iter.map(|e| e.unwrap().file_name()).collect::<Vec<_>>();
assert!(file_names.is_empty());
// Deleting the directory should succeed.
remove_dir(&dir_path).unwrap();
// Reading the metadata of a non-existent file should fail with a "not found" error.
// Reading the metadata of a non-existent directory should fail with a "not found" error.
assert_eq!(ErrorKind::NotFound, check_metadata(&[], &dir_path).unwrap_err().kind());
}