Skip to content

Commit

Permalink
chore: fix clippy warning and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic committed Jul 27, 2023
1 parent c00ac2c commit 29dcacd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions yara-x/src/re/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,14 @@ impl Compiler {
fn visit_post_class(&mut self, class: &Class) -> Location {
match class {
Class::Bytes(class) => {
if let Some(byte) = class_to_hex_byte(&class) {
if let Some(byte) = class_to_hex_byte(class) {
self.emit_masked_byte(byte)
} else if self.case_insensitive {
let mut class = class.clone();
class.case_fold_simple();
self.emit_class(&class)
} else {
self.emit_class(&class)
self.emit_class(class)
}
}
Class::Unicode(class) => {
Expand Down
9 changes: 9 additions & 0 deletions yara-x/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,11 +832,20 @@ fn regexp_patterns_3() {

#[test]
fn regexp_nocase() {
pattern_match!(r#"/abc/ nocase"#, b"ABC", b"ABC");
pattern_match!(r#"/a[bx]c/ nocase"#, b"ABC", b"ABC");
pattern_match!(r#"/a[bx]c/ nocase"#, b"AXC", b"AXC");
pattern_match!(r#"/a[0-9]*b/ nocase"#, b"AB", b"AB");
pattern_match!(r#"/[a-z]+/ nocase"#, b"AbC", b"AbC");
pattern_match!(r#"/(abc|xyz)+/ nocase"#, b"AbCxYz", b"AbCxYz");
pattern_match!(r#"/(a|x)bc/ nocase"#, b"ABC", b"ABC");
pattern_match!(r#"/(a|x)bc/ nocase"#, b"XBC", b"XBC");

// TODO
//pattern_match!(r#"/abc[^d]/ nocase"#, b"abce", b"abce");
//pattern_match!(r#"/abc[^d]/ nocase"#, b"ABCE", b"ABCE");
//pattern_false!(r#"/abc[^d]/ nocase"#, b"abcd");
//pattern_false!(r#"/abc[^d]/ nocase"#, b"ABCD");
}

#[test]
Expand Down

0 comments on commit 29dcacd

Please sign in to comment.