Пример #1
0
 def test_corner0(self):
     dfa = DFA('b(ahigh)*a*low')
     self.assertTrue(dfa.evaluate_string('bahighalow'))
     self.assertTrue(dfa.evaluate_string('balow'))
     self.assertTrue(dfa.evaluate_string('blow'))
     self.assertTrue(dfa.evaluate_string('baaaalow'))
     self.assertTrue(dfa.evaluate_string('bahighlow'))
     self.assertTrue(dfa.evaluate_string('bahighaaaalow'))
     self.assertFalse(dfa.evaluate_string('bahigh'))
     self.assertTrue(dfa.evaluate_string('bahighahighalow'))
Пример #2
0
 def test_star0(self):
     dfa = DFA('a*')
     self.assertTrue(dfa.evaluate_string(''))
     self.assertTrue(dfa.evaluate_string('a'))
     self.assertTrue(dfa.evaluate_string('aa'))
     self.assertTrue(dfa.evaluate_string('aaaaaa'))
     self.assertTrue(dfa.evaluate_string('aaaaaaaa'))
     self.assertFalse(dfa.evaluate_string('b'))
     self.assertFalse(dfa.evaluate_string('aaabaa'))
     self.assertFalse(dfa.evaluate_string('aaab'))
Пример #3
0
 def test_star1(self):
     dfa = DFA('lola*lol')
     self.assertTrue(dfa.evaluate_string('lollol'))
     self.assertFalse(dfa.evaluate_string('lol'))
     self.assertFalse(dfa.evaluate_string('lola'))
     self.assertTrue(dfa.evaluate_string('lolaaaaaalol'))
     self.assertTrue(dfa.evaluate_string('lolalol'))
Пример #4
0
 def test_backslash(self):
     dfa = DFA('\\*')
     self.assertTrue(dfa.evaluate_string('*'))
     self.assertFalse(dfa.evaluate_string(''))
     self.assertFalse(dfa.evaluate_string('**'))
Пример #5
0
 def test_paren4(self):
     dfa = DFA('(lol)*')
     self.assertTrue(dfa.evaluate_string('lol'))
     self.assertTrue(dfa.evaluate_string(''))
     self.assertTrue(dfa.evaluate_string('lollol'))
     self.assertFalse(dfa.evaluate_string('loll'))
Пример #6
0
 def test_paren3(self):
     dfa = DFA('(lol)abc')
     self.assertTrue(dfa.evaluate_string('lolabc'))
     self.assertFalse(dfa.evaluate_string('(lol)'))
     self.assertFalse(dfa.evaluate_string('lol'))
     self.assertFalse(dfa.evaluate_string('abc'))
Пример #7
0
 def test_paren2(self):
     dfa = DFA('(lola*)')
     self.assertFalse(dfa.evaluate_string('lollol'))
     self.assertTrue(dfa.evaluate_string('lol'))
     self.assertTrue(dfa.evaluate_string('lola'))
     self.assertTrue(dfa.evaluate_string('lolaaaaaa'))
Пример #8
0
 def test_paren1(self):
     dfa = DFA('(lol|big)')
     self.assertTrue(dfa.evaluate_string('lol'))
     self.assertTrue(dfa.evaluate_string('big'))
     self.assertFalse(dfa.evaluate_string('lol|big'))
Пример #9
0
 def test_empty(self):
     dfa = DFA('')
     self.assertTrue(dfa.evaluate_string(''))
     self.assertFalse(dfa.evaluate_string('' + 'lol'))
Пример #10
0
 def test_and1(self):
     dfa = DFA('hello|')
     self.assertTrue(dfa.evaluate_string('hello'))
     self.assertFalse(dfa.evaluate_string('hello|'))
     self.assertTrue(dfa.evaluate_string(''))
Пример #11
0
 def test_normal1(self):
     dfa = DFA('hello world')
     self.assertTrue(dfa.evaluate_string('hello world'))
     self.assertFalse(dfa.evaluate_string('hello world' + 'lollol'))
     self.assertFalse(dfa.evaluate_string(''))
Пример #12
0
 def test_normal0(self):
     dfa = DFA('lol')
     self.assertTrue(dfa.evaluate_string('lol'))
     self.assertFalse(dfa.evaluate_string('lol' + 'lollol'))
     self.assertFalse(dfa.evaluate_string(''))