Test negation in tagged parser

This commit is contained in:
Félix Saparelli 2021-12-17 23:19:36 +13:00
parent debded9c0e
commit d38a78631f
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
1 changed files with 30 additions and 0 deletions

View File

@ -14,6 +14,22 @@ fn empty_filter() {
));
}
#[test]
fn only_bang() {
assert!(matches!(
Filter::from_str("!"),
Err(TaggedFiltererError::Parse { .. })
));
}
#[test]
fn no_op() {
assert!(matches!(
Filter::from_str("foobar"),
Err(TaggedFiltererError::Parse { .. })
));
}
#[test]
fn path_auto_op() {
assert_eq!(
@ -181,3 +197,17 @@ fn quoted_double() {
}
);
}
#[test]
fn negate() {
assert_eq!(
filter("!path~=^f[om]+$"),
Filter {
in_path: None,
on: Matcher::Path,
op: Op::Regex,
pat: Pattern::Regex(Regex::new("^f[om]+$").unwrap()),
negate: true,
}
);
}