Пример #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.')