示例#1
0
def test_unclosed_single_brackets():
    assert not is_valid_string('(')
    assert not is_valid_string('[')
    assert not is_valid_string('{')

    assert not is_valid_string(')')
    assert not is_valid_string(']')
    assert not is_valid_string('}')
示例#2
0
def test_incorrect_symbols():
    with pytest.raises(Exception):
        is_valid_string("a")

    with pytest.raises(Exception):
        is_valid_string("(b)")
示例#3
0
def test_deep_nested():
    input_string = "({[" * 10000 + "{}" * 2000 + "]})" * 10000
    assert is_valid_string(input_string)
示例#4
0
def test_long_string_with_enclosing():
    input_string = "(" + "{()[]}" * 10000 + ")"
    assert is_valid_string(input_string)
示例#5
0
def test_long_string_with_pattern():
    input_string = "{()[]}" * 10000
    assert is_valid_string(input_string)
示例#6
0
def test_invalid_with_correct_amount():
    assert not is_valid_string("[(])")
    assert not is_valid_string("[({}])")
示例#7
0
def test_invalid_examples_from_the_task():
    assert not is_valid_string("{)")
    assert not is_valid_string("{)(}")
示例#8
0
def test_valid_examples_from_the_task():
    assert is_valid_string("{[]()}")
    assert is_valid_string("(){}")
    assert is_valid_string("[(){}]")
示例#9
0
def test_nested():
    assert is_valid_string('(()[]{})')
    assert not is_valid_string('((})')
示例#10
0
def test_simplest_correct():
    assert is_valid_string('()')
    assert is_valid_string('[]')
    assert is_valid_string('{}')
示例#11
0
def test_empty():
    assert not is_valid_string('')