Skip to content

Commit

Permalink
full: add regression test for #35
Browse files Browse the repository at this point in the history
This bug had the same root cause as #37.
  • Loading branch information
BurntSushi committed Feb 16, 2019
1 parent 36f9887 commit 8a002bf
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ mod tests {
use quickcheck::{Arbitrary, Gen, quickcheck};
use rand::Rng;

use super::{AcAutomaton, Automaton, Match, AllBytesIter};
use super::{AcAutomaton, Automaton, Match, AllBytesIter, Dense};

fn aut_find<S>(xs: &[S], haystack: &str) -> Vec<Match>
where S: Clone + AsRef<[u8]> {
Expand Down Expand Up @@ -1113,4 +1113,18 @@ mod tests {
.collect::<Vec<(usize, usize)>>();
assert_eq!(matches1, matches2);
}

// See: https://github.com/BurntSushi/aho-corasick/issues/35
#[test]
fn regression_full_order3() {
let haystack: &'static [u8] = &[0, 0, 0];
let needles: Vec<&'static [u8]> = vec![
&[0, 0, 1],
&[0, 0, 0],
];

let aut = AcAutomaton::<_, Dense>::with_transitions(&needles[..])
.into_full();
assert_eq!(aut.find(&haystack).count(), 1);
}
}

0 comments on commit 8a002bf

Please sign in to comment.