Skip to content

Commit

Permalink
Improve iteration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Jun 27, 2023
1 parent 6f0a3c9 commit eca2592
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::{
driver,
fs::{Attribute, File, Filesystem},
io::{Error, OpenSeekFrom, Read, Result, SeekFrom},
path::PathBuf,
};

ram_storage!(
Expand Down Expand Up @@ -492,13 +493,15 @@ fn test_iter_dirs() {
tells.push(dir.tell()?);
let entry = entry?;

// assert_eq!(entry.file_name(), match i {
// 0 => b".\0",
// 1 => b"..\0",
// 2 => b"file.a\0",
// 3 => b"file.b\0",
// _ => panic!("oh noes"),
// });
let expected_name = match i {
0 => PathBuf::from(b".\0".as_slice()),
1 => PathBuf::from(b"..\0".as_slice()),
2 => PathBuf::from(b"file.a\0".as_slice()),
3 => PathBuf::from(b"file.b\0".as_slice()),
_ => panic!("oh noes"),
};

assert_eq!(entry.file_name(), &*expected_name);

sizes[i] = entry.metadata().len();
found_files += 1;
Expand All @@ -507,6 +510,7 @@ fn test_iter_dirs() {

assert_eq!(sizes, [0, 0, 37, 42]);
assert_eq!(found_files, 4);
assert_eq!(tells.len(), 5);

for (i, tell) in tells.iter().enumerate() {
dir.rewind().unwrap();
Expand Down

0 comments on commit eca2592

Please sign in to comment.