mod entrypoints;
mod header;
mod names;
mod read;
mod references;
mod selectors;
mod types;

pub use entrypoints::{inspect_win_bytes, inspect_win_file};
pub use types::*;

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn inspects_synthetic_window_blob() {
        let mut bytes = vec![0u8; 0x90];
        bytes[0x00..0x04].copy_from_slice(&0x0000_07d0u32.to_le_bytes());
        bytes[0x0c..0x10].copy_from_slice(&0x8000_0000u32.to_le_bytes());
        bytes[0x10..0x14].copy_from_slice(&0x8000_003fu32.to_le_bytes());
        bytes[0x14..0x18].copy_from_slice(&0x0000_003fu32.to_le_bytes());
        bytes[0x34..0x38].copy_from_slice(&0x0007_d100u32.to_le_bytes());
        bytes[0x38..0x3c].copy_from_slice(&0x0007_d200u32.to_le_bytes());
        bytes[0x40..0x44].copy_from_slice(&0x000b_b800u32.to_le_bytes());
        bytes[0x48..0x4c].copy_from_slice(&0x000b_b900u32.to_le_bytes());
        bytes[0x50] = 0;
        bytes[0x51..0x51 + "Root.imb".len()].copy_from_slice(b"Root.imb");
        bytes[0x59] = 0;
        bytes.extend_from_slice(b"\0Button.imb\0");

        let report = inspect_win_bytes(&bytes).expect("inspection should succeed");
        assert!(report.matches_observed_common_signature);
        assert_eq!(
            report.inline_root_resource_name.as_deref(),
            Some("Root.imb")
        );
        assert_eq!(report.imb_reference_count, 2);
        assert_eq!(report.unique_imb_reference_count, 2);
        assert_eq!(report.resource_selector_records.len(), 2);
        assert_eq!(report.resource_selector_records[0].name, "Root.imb");
        assert!(report.anonymous_selector_records.is_empty());
    }
}
