예제 #1
0
def test_five_nodes():
    t = Tree()
    t.right = Tree()
    t.right.right = Tree()
    t.left = Tree()
    t.left.left = Tree()
    assert_that(max_distance(t), equal_to(4))
예제 #2
0
def test_eight_nodes_unbalanced():
    t = Tree()
    t.right = Tree()

    t.right.left = Tree()
    t.right.left.left = Tree()
    t.right.left.left.left = Tree()

    t.right.right = Tree()
    t.right.right.right = Tree()
    t.right.right.right.right = Tree()

    assert_that(max_distance(t), equal_to(6))
예제 #3
0
def test_two_nodes_left():
    t = Tree()
    t.left = Tree()
    assert_that(max_distance(t), equal_to(1))
예제 #4
0
def test_four_nodes_unbalanced_spread():
    t = Tree()
    t.right = Tree()
    t.right.right = Tree()
    t.left = Tree()
    assert_that(max_distance(t), equal_to(3))
예제 #5
0
def test_single_node():
    t = Tree()
    assert_that(max_distance(t), equal_to(0))