Skip to content

Instantly share code, notes, and snippets.

@timcowlishaw
Created October 25, 2011 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timcowlishaw/1312065 to your computer and use it in GitHub Desktop.
Save timcowlishaw/1312065 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe "AhoCorasick" do
it "returns matched substrings" do
a = AhoCorasick.new(["ab"])
a.match("abcde").should include("ab")
end
it "returns multiple matched substrings" do
a = AhoCorasick.new(["ab", "cd"])
a.match("cd123ab").to_set.should == ["ab", "cd"].to_set
end
it "returns overlapping matched substrings" do
a = AhoCorasick.new(["ab", "bc"])
a.match("abc").to_set.should == ["ab", "bc"].to_set
end
it "does not return unmatched substrings" do
a = AhoCorasick.new(["ab"])
a.match("abc").should_not include("bc")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment