Skip to content

Commit

Permalink
Write a simple unit test for search_regex()
Browse files Browse the repository at this point in the history
  • Loading branch information
yestyle committed Jan 28, 2024
1 parent 76156ed commit af7fe96
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,15 @@ fn main() {
}
});
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_search_regex() {
let file = File::open("tests/data/vmlinuz-6.4-x86_64").unwrap();
let offsets = search_regex(&file, r"\x1f\x8b\x08").unwrap();
assert_eq!(offsets, vec![0x0061bd72, 0x006b7b9e, 0x0085ab9f]);
}
}
Binary file added tests/data/vmlinuz-6.4-x86_64
Binary file not shown.

0 comments on commit af7fe96

Please sign in to comment.