fix: move Windows-only test cases to cfg-gated test function

This commit is contained in:
Abhay 2026-04-20 22:31:06 +05:30
parent a2d981aff9
commit 14bba8f264
1 changed files with 12 additions and 3 deletions

View File

@ -205,13 +205,22 @@ mod tests {
#[case(&["foo", "o", "bar"], "/foo/bar", false)]
#[case(&["/foo/", "/bar"], "/foo/bar", false)]
#[case(&["/foo/", "/bar"], "/foo/baz/bar", true)]
// Forward slash matching on Windows-style paths
#[case(&["bar/meow"], r"~\foo\bar\meow", true)]
#[case(&["bar", "meow"], r"~\foo\bar\meow", true)]
fn query(#[case] keywords: &[&str], #[case] path: &str, #[case] is_match: bool) {
let db = &mut Database::new(PathBuf::new(), Vec::new(), |_| Vec::new(), false);
let options = StreamOptions::new(0).with_keywords(keywords.iter());
let stream = Stream::new(db, options);
assert_eq!(is_match, stream.filter_by_keywords(path));
}
// Forward slash matching on Windows-style paths
#[cfg(windows)]
#[rstest]
#[case(&["bar/meow"], r"~\foo\bar\meow", true)]
#[case(&["bar", "meow"], r"~\foo\bar\meow", true)]
fn query_windows(#[case] keywords: &[&str], #[case] path: &str, #[case] is_match: bool) {
let db = &mut Database::new(PathBuf::new(), Vec::new(), |_| Vec::new(), false);
let options = StreamOptions::new(0).with_keywords(keywords.iter());
let stream = Stream::new(db, options);
assert_eq!(is_match, stream.filter_by_keywords(path));
}
}