Example #1
0
 def test_kleene_op(self):
     nfa = O.tree2nfa(O.regex2tree('a*'))
     self.assertTrue(O.match(nfa, ''))
     self.assertTrue(O.match(nfa, 'a'))
     self.assertTrue(O.match(nfa, 'aa'))
     self.assertTrue(O.match(nfa, 'aaaaaaaaa'))
     self.assertFalse(O.match(nfa, 'aaaaabbbbaaaa'))
     self.assertFalse(O.match(nfa, 'bbba'))
Example #2
0
 def test_empty_string(self):
     nfa1 = O.tree2nfa(O.regex2tree('a*'))
     nfa2 = O.tree2nfa(O.regex2tree('a'))
     self.assertTrue(O.match(nfa1, ''))
     self.assertFalse(O.match(nfa2, ''))
Example #3
0
 def test_single_character(self):
     nfa = O.tree2nfa(O.regex2tree('a'))
     self.assertTrue(O.match(nfa, 'a'))
     self.assertFalse(O.match(nfa, ''))
     self.assertFalse(O.match(nfa, 'aa'))
     self.assertFalse(O.match(nfa, 'ab'))