mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2024-12-12 19:18:24 +02:00
grep: remove senseless test
It was pulling in a sizable data file and doesn't appear to be testing anything meaningful that isn't covered by a variety of other tests.
This commit is contained in:
parent
deb1de6e1e
commit
94be3bd4bb
File diff suppressed because it is too large
Load Diff
@ -315,42 +315,3 @@ impl<'b, 's> Iterator for Iter<'b, 's> {
|
||||
Some(mat)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use memchr::{memchr, memrchr};
|
||||
use regex::bytes::Regex;
|
||||
|
||||
use super::{GrepBuilder, Match};
|
||||
|
||||
static SHERLOCK: &'static [u8] = include_bytes!("./data/sherlock.txt");
|
||||
|
||||
fn find_lines(pat: &str, haystack: &[u8]) -> Vec<Match> {
|
||||
let re = Regex::new(pat).unwrap();
|
||||
let mut lines = vec![];
|
||||
for m in re.find_iter(haystack) {
|
||||
let start = memrchr(b'\n', &haystack[..m.start()])
|
||||
.map_or(0, |i| i + 1);
|
||||
let end = memchr(b'\n', &haystack[m.end()..])
|
||||
.map_or(haystack.len(), |i| m.end() + i + 1);
|
||||
lines.push(Match {
|
||||
start: start,
|
||||
end: end,
|
||||
});
|
||||
}
|
||||
lines
|
||||
}
|
||||
|
||||
fn grep_lines(pat: &str, haystack: &[u8]) -> Vec<Match> {
|
||||
let g = GrepBuilder::new(pat).build().unwrap();
|
||||
g.iter(haystack).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn buffered_literal() {
|
||||
let expected = find_lines("Sherlock Holmes", SHERLOCK);
|
||||
let got = grep_lines("Sherlock Holmes", SHERLOCK);
|
||||
assert_eq!(expected.len(), got.len());
|
||||
assert_eq!(expected, got);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user