コード例 #1
0
def random_str_sll():
    sll = SinglyLinkedList('TEST Example String SLL', str)
    for _ in range(random.randint(1, 16)):
        random_string = ''.join(
                random.choice(string.ascii_letters + string.digits)
                for _ in range(random.randint(1, 5)))
        sll.append(random_string)
    return sll
コード例 #2
0
def full_int_sll():
    sll = SinglyLinkedList('', int, 4)
    sll.append(1)
    sll.append(2)
    sll.append(3)
    sll.append(4)
    return sll
コード例 #3
0
def test_constructor_with_invalid_type():
    with pytest.raises(TypeError):
        set_sll = SinglyLinkedList('my set sll', set)
コード例 #4
0
def test_constructor_with_invalid_size_limit():
    with pytest.raises(IndexError):
        int_sll = SinglyLinkedList('my int sll', int, -1)
コード例 #5
0
def test_constructor_with_excessive_size_limit():
    float_sll = SinglyLinkedList('my float sll', float, 20)
    assert float_sll.max_size == 16
コード例 #6
0
def test_constructor_with_custom_size_limit():
    str_sll = SinglyLinkedList('my str sll', str, 15)
    assert str_sll.max_size == 15
コード例 #7
0
def test_constructor_with_default_size_limit():
    int_sll = SinglyLinkedList('my int sll', int)
    assert int_sll.max_size == 16
コード例 #8
0
def random_float_sll():
    sll = SinglyLinkedList('TEST Example Float SLL', float)
    for _ in range(random.randint(1, 16)):
        sll.append(random.random() * random.randint(-1000, 1000))
    return sll
コード例 #9
0
def random_int_sll():
    sll = SinglyLinkedList('TEST Example Integer SLL', int)
    for _ in range(random.randint(1, 16)):
        sll.append(random.randint(-999, 999))
    return sll
コード例 #10
0
def empty_str_sll():
    return SinglyLinkedList('', str)
コード例 #11
0
def empty_int_sll():
    return SinglyLinkedList('', int)