def test_leaf(self: 'TestBuildRegexTree') -> None: """Correctly builds leaves?""" leaf_list = [(LE, 'e'), (L0, '0'), (L1, '1'), (L2, '2')] for t in leaf_list: self.assertEqual( t[0], build_regex_tree(t[1]), "Regex tree {} doesn't match {}.".format(t[0], t[1]))
def test_star(self: 'TestBuildRegexTree') -> None: """Correctly builds star trees?""" star_list = [(S(L1), '1*'), (S(LE), 'e*'), (S(L0), '0*'), (S(L2), '2*')] for t in star_list: self.assertEqual( t[0], build_regex_tree(t[1]), "Regex tree {} doesn't match {}.".format(t[0], t[1]))
def test_bar(self: 'TestBuildRegexTree') -> None: """Correctly builds bar trees?""" bar_list = [(B(L0, L1), '(0|1)'), (B(LE, L1), '(e|1)'), (B(L1, LE), '(1|e)'), (B(L2, L2), '(2|2)')] for t in bar_list: self.assertEqual( t[0], build_regex_tree(t[1]), "Regex tree {} doesn't match {}.".format(t[0], t[1]))
def test_dot(self: 'TestBuildRegexTree') -> None: """Correctly builds dot trees?""" dot_list = [(D(L0, L1), '(0.1)'), (D(LE, L1), '(e.1)'), (D(L1, LE), '(1.e)'), (D(L2, L2), '(2.2)')] for t in dot_list: self.assertEqual( t[0], build_regex_tree(t[1]), "Regex tree {} doesn't match {}.".format(t[0], t[1]))
def test_dot_star(self: 'TestBuildRegexTree') -> None: """Correctly builds dot-star trees?""" dot_star_list = [(D(L0, S(L1)), '(0.1*)'), (D(S(L0), L1), '(0*.1)'), (D(S(L1), S(L2)), '(1*.2*)'), (S(D(L0, L1)), '(0.1)*'), (S(D(S(L0), L1)), '(0*.1)*'), (S(D(S(L0), D(L1, S(L2)))), '(0*.(1.2*))*')] for t in dot_star_list: self.assertEqual( t[0], build_regex_tree(t[1]), "Regex tree {} doesn't match {}.".format(t[0], t[1]))
def test_bar_star(self: 'TestBuildRegexTree') -> None: """Correctly builds bar-star trees?""" bar_star_list = [(B(L0, S(L1)), '(0|1*)'), (B(S(L0), L1), '(0*|1)'), (B(S(L1), S(L2)), '(1*|2*)'), (S(B(L0, L1)), '(0|1)*'), (S(B(S(L0), L1)), '(0*|1)*'), (S(B(S(L0), B(L1, S(L2)))), '(0*|(1|2*))*')] for t in bar_star_list: self.assertEqual( t[0], build_regex_tree(t[1]), "Regex tree {} doesn't match {}.".format(t[0], t[1]))
def test_bar_dot_star(self: 'TestBuildRegexTree') -> None: """Correctly builds bar-dot-star trees?""" bar_dot_star_list = [ (B(D(L0, L1), D(S(L2), LE)), '((0.1)|(2*.e))'), (D(B(L0, L1), B(S(L2), LE)), '((0|1).(2*|e))'), (S(D(B(L0, L1), D(S(L2), LE))), '((0|1).(2*.e))*'), (S(B(D(L0, L1), B(S(L2), LE))), '((0.1)|(2*|e))*'), (S(D((L0), B(S(L2), LE))), '(0.(2*|e))*'), ] for t in bar_dot_star_list: self.assertEqual( t[0], build_regex_tree(t[1]), "Regex tree {} doesn't match {}.".format(t[0], t[1]))
def test_bar_dot(self: 'TestBuildRegexTree') -> None: """Correctly builds bar-dot trees?""" bar_dot_list = [(B(D(L0, L1), D(L2, LE)), '((0.1)|(2.e))'), (B(B(L0, L1), D(L2, LE)), '((0|1)|(2.e))'), (B(D(L0, L1), B(L2, LE)), '((0.1)|(2|e))'), (B(D(L1, L2), L0), '((1.2)|0)'), (B(L1, D(L2, L0)), '(1|(2.0))'), (D(B(L0, L1), B(L2, LE)), '((0|1).(2|e))'), (D(D(L0, L1), B(L2, LE)), '((0.1).(2|e))'), (D(B(L0, L1), D(L2, LE)), '((0|1).(2.e))')] for t in bar_dot_list: self.assertEqual( t[0], build_regex_tree(t[1]), "Regex tree {} doesn't match {}.".format(t[0], t[1]))