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