summaryrefslogtreecommitdiffstats
path: root/grep/src/search.rs
diff options
context:
space:
mode:
Diffstat (limited to 'grep/src/search.rs')
-rw-r--r--grep/src/search.rs39
1 files changed, 0 insertions, 39 deletions
diff --git a/grep/src/search.rs b/grep/src/search.rs
index 49ddf1f8..af7d680d 100644
--- a/grep/src/search.rs
+++ b/grep/src/search.rs
@@ -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);
- }
-}