//! The Messages reader's decisions, one row at a time and without a database.usesuper::*;#[test]fn it_reads_a_nanosecond_stamp_as_the_instant_it_names() {// 2026-09-08T10:00:00Z is 810_554_400 seconds after Apple's epoch.let seconds: i64 = 810_554_400; assert_eq!( apple_date_to_iso(Some(seconds * 1_000_000_000)).as_deref(),Some("2026-09-08T10:00:00.000Z") );}#[test]fn it_reads_an_older_files_seconds_by_their_magnitude_alone() {let seconds: i64 = 810_554_400; assert_eq!( apple_date_to_iso(Some(seconds)).as_deref(),Some("2026-09-08T10:00:00.000Z") );}#[test]fn a_zero_date_means_the_row_never_got_one_and_is_not_the_year_2001() { assert_eq!(apple_date_to_iso(Some(0)), None); assert_eq!(apple_date_to_iso(Some(-1)), None); assert_eq!(apple_date_to_iso(None), None);}#[test]fn an_absurd_stamp_is_arithmetic_that_holds_rather_than_a_panic() {// The TypeScript answered `null` only when `new Date` gave an Invalid Date,// which is ±8.64e15 ms away — further than any value this column can hold.// So the largest stamp there is has a real instant, and the checked// arithmetic here exists so a corrupt row can never be a crash mid-import. assert!(apple_date_to_iso(Some(i64::MAX)).is_some());}#[test]fn a_bare_national_number_is_promoted_to_the_stated_country_never_a_guessed_one() {let handle = read_handle(Some("9876543210"), DEFAULT_COUNTRY_CODE).expect("a handle"); assert_eq!(handle.kind, HandleKind::Phone); assert_eq!(handle.value, "919876543210"); assert_eq!(handle.raw, "9876543210");}#[test]fn an_apple_id_is_an_email_identity_and_is_lower_cased() {let handle = read_handle(Some(" Someone@Example.COM "), DEFAULT_COUNTRY_CODE).expect("a handle"); assert_eq!(handle.kind, HandleKind::Email); assert_eq!(handle.value, "someone@example.com"); assert_eq!(handle.raw, "Someone@Example.COM");}#[test]fn a_sender_id_that_is_a_word_stays_a_label_and_never_becomes_a_number() {// Most handles in a real file are these: bank alerts, OTP senders,// deliveries. Forcing one into a phone files a bank under a number that is// not a number.let handle = read_handle(Some("AX-BANKOTP"), DEFAULT_COUNTRY_CODE).expect("a handle"); assert_eq!(handle.kind, HandleKind::Label); assert_eq!(handle.value, "AX-BANKOTP");}#[test]fn something_with_an_at_sign_that_is_not_an_address_is_a_label_not_an_email() {for raw in ["@", "a@", "@b", "a@b@c", "two words@example.com"] { assert_eq!( read_handle(Some(raw), DEFAULT_COUNTRY_CODE) .expect("a handle") .kind,HandleKind::Label,"{raw}" ); }}#[test]fn an_empty_handle_is_no_handle_at_all() { assert_eq!(read_handle(Some(" "), DEFAULT_COUNTRY_CODE), None); assert_eq!(read_handle(None, DEFAULT_COUNTRY_CODE), None);}