#[cfg(test)]
mod tests {
use crate::source::multi::merger::leading_timestamp;
#[test]
fn extracts_iso_prefix() {
let line = "2025-04-14T18:22:01 request handled";
assert_eq!(leading_timestamp(line), Some("2025-04-14T18:22:01"));
}
#[test]
fn rejects_short_line() {
assert_eq!(leading_timestamp("short"), None);
}
#[test]
fn rejects_missing_t() {
let line = "2025-04-14 18:22:01 request";
assert_eq!(leading_timestamp(line), None);
}
#[test]
fn rejects_non_digit() {
let line = "2025-04-14T18:AA:01 request";
assert_eq!(leading_timestamp(line), None);
}
#[test]
fn rejects_trailing_junk_in_prefix() {
let line = "2025+04-14T18:22:01 hello";
assert_eq!(leading_timestamp(line), None);
}
#[test]
fn accepts_when_exactly_prefix_length() {
let line = "2025-04-14T18:22:01";
assert_eq!(leading_timestamp(line), Some("2025-04-14T18:22:01"));
}
#[test]
fn accepts_with_ms_suffix() {
let line = "2025-04-14T18:22:01.123Z request";
assert_eq!(leading_timestamp(line), Some("2025-04-14T18:22:01"));
}
}