Skip to main content

chat4n6_plugin_api/
lib.rs

1// chat4n6-plugin-api
2
3pub mod fs;
4pub mod types;
5
6pub use fs::*;
7pub use types::*;
8
9#[cfg(test)]
10mod tests {
11    use super::*;
12
13    #[test]
14    fn test_evidence_source_display() {
15        assert_eq!(format!("{}", EvidenceSource::Live), "LIVE");
16        assert_eq!(format!("{}", EvidenceSource::WalPending), "WAL-PENDING");
17        assert_eq!(format!("{}", EvidenceSource::WalHistoric), "WAL-HISTORIC");
18        assert_eq!(format!("{}", EvidenceSource::Freelist), "FREELIST");
19        assert_eq!(format!("{}", EvidenceSource::FtsOnly), "FTS-ONLY");
20        assert_eq!(
21            format!("{}", EvidenceSource::CarvedUnalloc { confidence_pct: 94 }),
22            "CARVED-UNALLOC 94%"
23        );
24        assert_eq!(format!("{}", EvidenceSource::CarvedDb), "CARVED-DB");
25    }
26
27    #[test]
28    fn test_timestamp_utc_str() {
29        let ts = ForensicTimestamp::from_millis(1710513127000, 0);
30        assert_eq!(ts.utc_str(), "2024-03-15 14:32:07 UTC");
31    }
32
33    #[test]
34    fn test_timestamp_local_str_positive_offset() {
35        let ts = ForensicTimestamp::from_millis(1710513127000, 8 * 3600);
36        assert_eq!(
37            ts.local_str(),
38            "2024-03-15 14:32:07 UTC  |  2024-03-15 22:32:07 +08:00"
39        );
40    }
41
42    #[test]
43    fn test_timestamp_local_str_negative_offset() {
44        let ts = ForensicTimestamp::from_millis(1710513127000, -5 * 3600);
45        assert_eq!(
46            ts.local_str(),
47            "2024-03-15 14:32:07 UTC  |  2024-03-15 09:32:07 -05:00"
48        );
49    }
50
51    #[test]
52    fn test_timestamp_local_str_utc() {
53        let ts = ForensicTimestamp::from_millis(1710513127000, 0);
54        assert_eq!(
55            ts.local_str(),
56            "2024-03-15 14:32:07 UTC  |  2024-03-15 14:32:07 +00:00"
57        );
58    }
59
60    #[test]
61    fn test_timestamp_local_str_subhour_offset() {
62        // India Standard Time = UTC+05:30
63        let ts = ForensicTimestamp::from_millis(1710513127000, 5 * 3600 + 30 * 60);
64        assert_eq!(
65            ts.local_str(),
66            "2024-03-15 14:32:07 UTC  |  2024-03-15 20:02:07 +05:30"
67        );
68    }
69
70    #[test]
71    fn test_extraction_result_default_empty() {
72        let r = ExtractionResult::default();
73        assert!(r.chats.is_empty());
74        assert!(r.calls.is_empty());
75        assert!(r.wal_deltas.is_empty());
76        assert!(r.timezone_offset_seconds.is_none());
77    }
78}