예제 #1
0
def test_nontrivial():
    head = LinkedListNode(
        0, LinkedListNode(1, LinkedListNode(2, LinkedListNode(3))))
    expected = LinkedListNode(
        0, LinkedListNode(3, LinkedListNode(1, LinkedListNode(2))))
    reorder(head)
    assert is_same(head, expected)
def test_nontrivial():
    # 2 -> 0 -> 2 -> 2 -> 1 -> 2 => 0 -> 1

    head1 = LinkedListNode(2)
    node1 = LinkedListNode(0)
    node2 = LinkedListNode(2)
    node3 = LinkedListNode(2)
    node4 = LinkedListNode(1)
    node5 = LinkedListNode(2)
    head1.next = node1
    node1.next = node2
    node2.next = node3
    node3.next = node4
    node4.next = node5

    head2 = LinkedListNode(0)
    node6 = LinkedListNode(1)
    head2.next = node6

    assert is_same(remove(head1, 2), head2)
예제 #3
0
def test_trivial_true():
    head1 = LinkedListNode(0)
    head2 = LinkedListNode(0)
    assert is_same(head1, head2)
예제 #4
0
def test_trivial():
    assert is_same(None, None)
예제 #5
0
def test_nontrivial_false():
    head1 = LinkedListNode(0, LinkedListNode(1, LinkedListNode(2)))
    head2 = LinkedListNode(0, LinkedListNode(1))
    assert not is_same(head1, head2)
예제 #6
0
def test_trivial_false():
    head1 = LinkedListNode(0)
    head2 = LinkedListNode(1)
    assert not is_same(head1, head2)
def test_nontrivial_true():
    head1 = LinkedListNode(0, LinkedListNode(1, LinkedListNode(2)))
    head2 = LinkedListNode(2, LinkedListNode(1, LinkedListNode(0)))
    assert is_same(reverse(head1), head2)
예제 #8
0
def test_trivial():
    head = LinkedListNode(0)
    reorder(head)
    expected = LinkedListNode(0)
    assert is_same(head, expected)
예제 #9
0
def test_trivial():
    head1 = LinkedListNode(0)
    insert_after(head1, 1)
    head2 = LinkedListNode(0, LinkedListNode(1))
    assert is_same(head1, head2)
예제 #10
0
def test_nontrivial():
    head1 = LinkedListNode(1, LinkedListNode(3))
    head2 = LinkedListNode(1, LinkedListNode(2, LinkedListNode(3)))
    insert_after(head1, 2)
    assert is_same(head1, head2)
예제 #11
0
def test_trivial():
    head1 = LinkedListNode(0, LinkedListNode(1))
    delete_after(head1)
    head2 = LinkedListNode(0)
    assert is_same(head1, head2)