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
def full_int_sll(): sll = SinglyLinkedList('', int, 4) sll.append(1) sll.append(2) sll.append(3) sll.append(4) return sll
def test_constructor_with_invalid_type(): with pytest.raises(TypeError): set_sll = SinglyLinkedList('my set sll', set)
def test_constructor_with_invalid_size_limit(): with pytest.raises(IndexError): int_sll = SinglyLinkedList('my int sll', int, -1)
def test_constructor_with_excessive_size_limit(): float_sll = SinglyLinkedList('my float sll', float, 20) assert float_sll.max_size == 16
def test_constructor_with_custom_size_limit(): str_sll = SinglyLinkedList('my str sll', str, 15) assert str_sll.max_size == 15
def test_constructor_with_default_size_limit(): int_sll = SinglyLinkedList('my int sll', int) assert int_sll.max_size == 16
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
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
def empty_str_sll(): return SinglyLinkedList('', str)
def empty_int_sll(): return SinglyLinkedList('', int)