mod builder;
use builder::E01Builder;
use ewf_forensic::{AnalysisProgress, EwfIntegrityPath};
use std::io::Write as _;
use tempfile::NamedTempFile;
fn write_temp(data: &[u8]) -> NamedTempFile {
let mut f = NamedTempFile::with_suffix(".E01").unwrap();
f.write_all(data).unwrap();
f.flush().unwrap();
f
}
#[test]
fn path_analyse_with_progress_matches_analyse() {
let image = E01Builder::new(512 * 64).build();
let f = write_temp(&image);
let checker = EwfIntegrityPath::from_path(f.path());
let standalone = checker.analyse().unwrap();
let (with_progress, _) = checker
.analyse_with_progress(|_p: AnalysisProgress| {})
.unwrap();
assert_eq!(
standalone.len(),
with_progress.len(),
"anomaly count must match between analyse() and analyse_with_progress()"
);
}
#[test]
fn path_analyse_with_progress_callback_invoked() {
let image = E01Builder::new(512 * 64 * 4).build(); let f = write_temp(&image);
let mut call_count = 0usize;
EwfIntegrityPath::from_path(f.path())
.analyse_with_progress(|_p: AnalysisProgress| { call_count += 1; })
.unwrap();
assert!(call_count > 0, "progress callback must be invoked at least once");
}