コード例 #1
0
def full_list():
    new_list = DoubleLink([1, 2, 3])
    return new_list
コード例 #2
0
def test_multi_value_list_with_parens():
    """Test that you can create a list with a string of parens."""
    new_list = DoubleLink(')()()()')
    assert new_list.head.value == ')'
コード例 #3
0
def test_create_empty_dll():
    """Test whether we create an empty list."""
    new_list = DoubleLink()
    assert new_list._length is 0
コード例 #4
0
def test_create_one_value_list():
    """Test that you can create list with one value."""
    new_list = DoubleLink(')')
    assert new_list._length == 1
コード例 #5
0
def balanced_list():
    new_list = DoubleLink(')()()()(')
    return new_list
コード例 #6
0
def test_create_list_raise_error():
    """Test that TypeError is raised when you init with noniterable."""
    with pytest.raises(TypeError):
        new_dll = DoubleLink(iterable=123456)
コード例 #7
0
def test_balanced_tail_closed_returns_0():
    """Test that a list with a closed tail returns 0."""
    new_list = DoubleLink(')()(')
    assert new_list.tail.value == ')'
    assert new_list.balanced() == 0
コード例 #8
0
def open_list():
    new_list = DoubleLink(')(()(')
    return new_list
コード例 #9
0
def test_balanced_tail_open():
    """Test that a list with an open tail returns 1."""
    new_list = DoubleLink('(()(')
    assert new_list.tail.value == '('
    assert new_list.balanced() == 1
コード例 #10
0
def test_balanced_empty_list():
    """Test that an empty list returns a value error."""
    new_list = DoubleLink()
    with pytest.raises(ValueError):
        new_list.balanced()
コード例 #11
0
def broken_list():
    new_list = DoubleLink(')())(')
    return new_list
コード例 #12
0
def test_balanced_first_node_closed_paren():
    """Check that balanced returns -1 when head is ')'."""
    new_list = DoubleLink('()')
    assert new_list.balanced() == -1
コード例 #13
0
def test_push_tail_node_empty_list():
    """Test that when you push to an empty list, the head is also the tail."""
    new_list = DoubleLink()
    new_list.push(15)
    assert new_list.tail.value == 15