#![allow(clippy::unwrap_used, clippy::expect_used)]
use timeglyph::interpret;
const FILETIME_WHOLE_SECOND: i64 = 132_225_120_000_000_000;
const FILETIME_SUBSEC_NONZERO: i64 = 132_225_120_000_000_001;
#[test]
fn filetime_zero_subsecond_carries_timestomp_annotation() {
let cands = interpret::interpret_int(FILETIME_WHOLE_SECOND);
let ft = cands
.iter()
.find(|c| c.format_id == "filetime")
.expect("filetime candidate must be present");
let joined = ft.assumptions.join(" ").to_lowercase();
assert!(
joined.contains("consistent with") && joined.contains("manipulation"),
"a filetime with zero sub-second field must carry a 'consistent with … manipulation' assumption; got: {:?}",
ft.assumptions
);
assert!(
!joined.contains("was timestomped") && !joined.contains("is timestomped"),
"must NOT use verdict language ('was timestomped' / 'is timestomped'): {:?}",
ft.assumptions
);
}
#[test]
fn filetime_nonzero_subsecond_no_timestomp_annotation() {
let cands = interpret::interpret_int(FILETIME_SUBSEC_NONZERO);
let ft = cands
.iter()
.find(|c| c.format_id == "filetime")
.expect("filetime candidate must be present");
let joined = ft.assumptions.join(" ").to_lowercase();
assert!(
!joined.contains("manipulation"),
"a filetime with non-zero sub-second field must NOT carry a manipulation note; got: {:?}",
ft.assumptions
);
}
#[test]
fn active_zero_subsecond_gets_no_filetime_manipulation_note() {
let cands = interpret::interpret_int(FILETIME_WHOLE_SECOND);
if let Some(active) = cands.iter().find(|c| c.format_id == "active") {
let joined = active.assumptions.join(" ").to_lowercase();
assert!(
!joined.contains("setfiletime") && !joined.contains("manipulation"),
"active (AD) must NOT carry the SetFileTime manipulation note; got: {:?}",
active.assumptions
);
}
}
#[test]
fn dotnet_ticks_zero_subsecond_no_annotation() {
const DOTNET_WHOLE_SECOND: i64 = 637_455_456_000_000_000;
let cands = interpret::interpret_int(DOTNET_WHOLE_SECOND);
if let Some(dn) = cands.iter().find(|c| c.format_id == "dotnet_ticks") {
let joined = dn.assumptions.join(" ").to_lowercase();
assert!(
!joined.contains("setfiletime") && !joined.contains("manipulation"),
"dotnet_ticks must NOT carry the SetFileTime manipulation note; got: {:?}",
dn.assumptions
);
}
}