pmat 3.26.0

PMAT - Zero-config AI context generation and code quality toolkit (CLI, MCP, HTTP)
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_is_code_file() {
        assert!(is_code_file(Path::new("test.rs")));
        assert!(is_code_file(Path::new("test.js")));
        assert!(!is_code_file(Path::new("test.txt")));
    }

    #[test]
    fn test_extract_names() {
        let content = "fn test_function() {}\nstruct TestStruct {}";
        let names = extract_names(content, "test.rs", crate::cli::SearchScope::All)
            .expect("internal error");
        assert_eq!(names.len(), 2);
        assert_eq!(names[0].0, "test_function");
        assert_eq!(names[1].0, "TestStruct");
    }

    #[test]
    fn test_find_similar_names() {
        let candidates = vec![
            (
                "test_function".to_string(),
                "test.rs".to_string(),
                1,
                "function".to_string(),
            ),
            (
                "test_func".to_string(),
                "test.rs".to_string(),
                2,
                "function".to_string(),
            ),
            (
                "unrelated".to_string(),
                "test.rs".to_string(),
                3,
                "function".to_string(),
            ),
        ];

        let matches = find_similar_names("test_fun", candidates, 0.5, false, false, false)
            .expect("internal error");

        assert!(matches.len() >= 2);
        assert!(matches.iter().any(|m| m.name == "test_function"));
        assert!(matches.iter().any(|m| m.name == "test_func"));
    }
}