示例#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))