use std::path::Path;
pub fn is_example_path(path: &Path) -> bool {
path.to_string_lossy().contains("examples/")
}
pub fn is_bench_path(path: &Path) -> bool {
path.to_string_lossy().contains("benches/")
}
pub fn is_test_path(path: &Path) -> bool {
path.to_string_lossy().contains("tests/")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_example_paths() {
assert!(is_example_path(Path::new("examples/main.rs")));
assert!(is_example_path(Path::new("crate/examples/demo.rs")));
assert!(!is_example_path(Path::new("src/examples.rs")));
}
#[test]
fn test_bench_paths() {
assert!(is_bench_path(Path::new("benches/perf.rs")));
assert!(!is_bench_path(Path::new("src/benches.rs")));
}
#[test]
fn test_test_paths() {
assert!(is_test_path(Path::new("tests/integration.rs")));
assert!(!is_test_path(Path::new("src/tests.rs")));
}
}