示例#1
0
def test_single_character():
    assert to_postfix('^a$') == as_list_of_tokens('a')
示例#2
0
def test_mixed_operators():
    with pytest.raises(MalformedRegex):
        to_postfix('???+*+++**?')
示例#3
0
def test_incorred_mixed_operators_and_characters():
    with pytest.raises(MalformedRegex):
        to_postfix('a+???a+bc**')
示例#4
0
def test_one_character_question_mark():
    assert to_postfix('^a?$') == as_list_of_tokens('a?')
示例#5
0
def test_three_plus_operators():
    with pytest.raises(MalformedRegex):
        to_postfix('+++')
示例#6
0
def test_four_characters():
    assert to_postfix('^abcd$') == as_list_of_tokens('ab.c.d.')
示例#7
0
def test_one_character_star():
    assert to_postfix('^a*$') == as_list_of_tokens('a*')
示例#8
0
def test_incorrect_expression_in_parenthesis():
    with pytest.raises(MalformedRegex):
        to_postfix('^a(+++)b$')
示例#9
0
def test_simple_alt():
    assert to_postfix('^a|b$') == as_list_of_tokens('ab|')
示例#10
0
def test_parenthesis_plus():
    assert to_postfix('^a(bc)+$') == as_list_of_tokens('abc.+.')
示例#11
0
def test_folded_parenthesis():
    assert to_postfix('^a(b+(cd)+)$') == as_list_of_tokens('ab+cd.+..')
示例#12
0
def test_redundant_parenthesis():
    assert to_postfix('^a(b)$') == as_list_of_tokens('ab.')
示例#13
0
def test_three_characters_with_pluses():
    assert to_postfix('^a+b+c+$') == as_list_of_tokens('a+b+.c+.')
示例#14
0
def test_one_character_question_mark_in_the_middle():
    assert to_postfix('^ab?c$') == as_list_of_tokens('ab?.c.')
示例#15
0
def test_two_characters():
    assert to_postfix('^ab$') == as_list_of_tokens('ab.')
示例#16
0
def test_alt_with_plus():
    assert to_postfix('^a+|b+$') == as_list_of_tokens('a+b+|')
示例#17
0
def test_three_characters():
    assert to_postfix('^abc$') == as_list_of_tokens('ab.c.')
示例#18
0
def test_alt_with_groups():
    assert to_postfix('^(abc)|(cde)$') == as_list_of_tokens('ab.c.cd.e.|')
示例#19
0
def test_one_character_plus():
    assert to_postfix('^a+$') == as_list_of_tokens('a+')
示例#20
0
def test_plus_operator_only():
    with pytest.raises(MalformedRegex):
        to_postfix('+')
示例#21
0
def test_character_plus_in_the_middle():
    assert to_postfix('^ab+c$') == as_list_of_tokens('ab+.c.')
示例#22
0
def test_character_star_in_the_middle():
    assert to_postfix('^ab*c$') == as_list_of_tokens('ab*.c.')