diff --git a/src/index.rs b/src/index.rs index c8067e8..13933db 100755 --- a/src/index.rs +++ b/src/index.rs @@ -160,4 +160,31 @@ impl Index2File { let hash = Index2File::calculate_hash(path); self.entries.iter().find(|s| s.hash == hash) } -} \ No newline at end of file +} + +#[cfg(test)] +mod tests { + use std::path::PathBuf; + + use super::*; + + #[test] + fn test_index_invalid() { + let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + d.push("resources/tests"); + d.push("random"); + + // Feeding it invalid data should not panic + IndexFile::from_existing(d.to_str().unwrap()); + } + + #[test] + fn test_index2_invalid() { + let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + d.push("resources/tests"); + d.push("random"); + + // Feeding it invalid data should not panic + Index2File::from_existing(d.to_str().unwrap()); + } +}