示例#1
0
 def test_match_all(self):
     for i in range(2, 1000):
         pat = random_string(random.randint(1, i))
         txt = random_string(i)
         expected = bool(pat in txt)
         assert modified_kmp.match(pat, txt) == expected
示例#2
0
 def test_no_match_4(self):
     """Test no match when pattern > text."""
     pat = 'l'
     txt = 'lFx0OyuczjmH'
     assert modified_kmp.match(pat, txt) == bool(pat in txt)
示例#3
0
 def test_match_kmp(self):
     pat = 'abcaby'
     txt = 'abxabcabcaby'
     assert modified_kmp.match(pat, txt) == bool(pat in txt)
示例#4
0
 def test_no_match_2(self):
     """Test no match when pattern > text."""
     pat = 'Ap'
     txt = 'poFfTzfHQAOD9Duwe9eB3gRaJIGIgyW35DWJjplV'
     assert modified_kmp.match(pat, txt) is False
示例#5
0
 def test_no_match_3(self):
     """Test no match when pattern > text."""
     pat = '6FjKojoBhRk8YbMH9fau0fHk9S38S5LcJ2LSzOApSw9ScEOlN4p0bKbbLlmurKYG0epr5O3RrU2avmQA1pPK02'  # noqa: E501
     txt = '02mTAg8avVRF01uKrsuuLJzKU36WzL6VUJiHvBDQxfA7PoN4vy9JR7oEg3x76yeRsEOOoDRNmwfXgEXIlmtjJrEwSp7ptRwFquP8u0'  # noqa: E501
     assert modified_kmp.match(pat, txt) == bool(pat in txt)
示例#6
0
 def test_incorrect_len(self):
     """Test no match when pattern > text."""
     pat = 'abcd'
     txt = 'abc'
     assert modified_kmp.match(pat, txt) is False
示例#7
0
 def test_no_match_6(self):
     """Test no matches."""
     pat = 'abc'
     txt = 'abdabdabe'
     assert modified_kmp.match(pat, txt) is False
示例#8
0
 def test_match_2(self):
     """Test matches on further iteration."""
     pat = 'abc'
     txt = 'abcdabcd'
     assert modified_kmp.match(pat, txt) is True
示例#9
0
 def test_kmp_match(self):
     """Test matches on first iteration."""
     pat = 'abc'
     txt = 'abcdabc'
     assert modified_kmp.match(pat, txt) is True
示例#10
0
 def test_no_match(self):
     pat = 'abc'
     txt = 'abdaabdc'
     assert modified_kmp.match(pat, txt) == bool(pat in txt)