Skip to content

Commit

Permalink
Merge pull request #297 from wcampbell0x2a/add-direntry-tests
Browse files Browse the repository at this point in the history
bh: Add tests for DirEntry
  • Loading branch information
wcampbell0x2a authored Oct 25, 2023
2 parents 0e2db95 + 0f42f29 commit 2757cdb
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,31 @@ impl DirectoryIndex {
std::str::from_utf8(&self.name).unwrap().to_string()
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn no_invalid_dir_entry() {
// just root
let dir = DirEntry {
offset: 0x300,
inode_offset: 0x0,
t: InodeId::BasicDirectory,
name_size: 0x1,
name: b"/".to_vec(),
};
assert_eq!(Path::new("/"), dir.name().unwrap());

// InvalidFilePath
let dir = DirEntry {
offset: 0x300,
inode_offset: 0x0,
t: InodeId::BasicDirectory,
name_size: 0x1,
name: b"/nice/".to_vec(),
};
assert!(dir.name().is_err());
}
}

0 comments on commit 2757cdb

Please sign in to comment.