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