def test_two_values_no_fizz():
    tree = BinaryTree()
    tree.root = Node(4)
    tree.root.left = Node(23)

    assert fizz_buzz_tree(tree).root.value == '4'
    assert fizz_buzz_tree(tree).root.left.value == '23'
def test_three_values_no_fizz():
    tree = BinaryTree()
    tree.root = Node(4)
    tree.root.left = Node(23)
    tree.root.right = Node(19)

    assert fizz_buzz_tree(tree).root.value == '4'
    assert fizz_buzz_tree(tree).root.left.value == '23'
    assert fizz_buzz_tree(tree).root.right.value == '19'
Exemple #3
0
def test_fizz_buzz():
    bt = BinaryTree()
    bt.root = Node(3)
    bt.root.right = Node(5)
    bt.root.left = Node(15)
    bt.root.left.left = Node(1)
    actual = FizzBuzzTree(bt)
    expect = ['Fizz', 'FizzBuzz', 1, 'Buzz']
    assert actual == expect
def test_fizz_buzz_imbalanced_tree():
    tree = BinaryTree()
    tree.add(10)
    tree.add(15)
    tree.add(20)
    tree.add(22)
    tree.add(91)
    tree.add(3000)
    tree = fizz_buzz_tree(tree)
    assert tree.root.value == 'Buzz'
    assert tree.root.right.right.right.right.right.value == 'FizzBuzz'
def test_tree():
    tree = BinaryTree()
    tree.root = Node(5)
    tree.root.left = Node(1)
    tree.root.right = Node(15)
    tree.root.left.left = Node(21)
    tree.root.left.right = Node(4)
    tree.root.right.right = Node(20)
    tree.root.left.left.left = Node(6)
    tree.root.right.right.left = Node(10)
    return tree
Exemple #6
0
def my_tree():
    tree = BinaryTree()
    tree._root = _Node(6)
    tree._root.left = _Node(15)
    tree._root.right = _Node(7)
    tree._root.left.left = _Node(23)
    tree._root.left.right = _Node(21)
    tree._root.right.right = _Node(5)
    tree._root.left.left.left = _Node(15)
    tree._root.right.right.left = _Node(7)
    return tree
def test_fizz_buzz():
    tree = BinaryTree()
    tree.root = Node(17)
    tree.root.left = Node(15)
    tree.root.right = Node(5)
    tree.root.right.left = Node(9)

    assert fizz_buzz_tree(tree).root.value == '17'
    assert fizz_buzz_tree(tree).root.left.value == 'FizzBuzz'
    assert fizz_buzz_tree(tree).root.right.value == 'Buzz'
    assert fizz_buzz_tree(tree).root.right.left.value == 'Fizz'
def test_creating_and_adding_to_BinaryTree():
    tree = BinaryTree()
    tree.add(10)
    tree.add(5)
    tree.add(15)
    assert tree.root.value == 10
    assert tree.root.left.value == 5
    assert tree.root.right.value == 15
def test_tree_instance():
    tree = BinaryTree()
    assert tree.root is None
def value_tree():
    tree = BinaryTree()
    tree.add(9)
    tree.add(7)
    tree.add(2)
    tree.add(3)
    tree.add(15)
    tree.add(42)
    tree.add(5)
    tree.add(4)
    tree.add(45)
    tree.add(6)
    tree.add(12)
    return tree
    """
def test_fizz_buzz_empty_tree():
    tree = BinaryTree()
    assert fizz_buzz_tree(tree) == "Empty Tree"
def ten_tree():
    tree = BinaryTree()
    tree.add(10)
    tree.add(5)
    tree.add(3)
    tree.add(6)
    tree.add(15)
    tree.add(90)
    tree.add(16)
    tree.add(101)
    tree.add(1)
    tree.add(3000)
    return tree
def test_empty_tree():
    tree = BinaryTree()
    new_tree = fizz_buzz_tree(tree)
    assert new_tree.root == None
def tree():
    return BinaryTree()