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():
    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_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 test_not_same_tree():

    tree = KaryTree(Node(1))

    clone = tree.clone()

    tree.root.value = 0

    assert tree.root.value == 0
    assert clone.root.value == 1
def tree():
    tree = KaryTree(Node(1))
    root = tree.root
    root.left = Node(2)
    root.right = Node(3)
    root.left.left = Node(4)
    root.left.right = Node(5)
    root.right.left = Node(15)
    return tree
Exemple #8
0
def test_one_to_15():

    one = Node(1)
    two = Node(2)
    three = Node(3)
    four = Node(4)
    five = Node(5)
    six = Node(6)
    seven = Node(7)
    eight = Node(8)
    nine = Node(9)
    ten = Node(10)
    eleven = Node(11)
    twelve = Node(12)
    thirteen = Node(13)
    fourteen = Node(14)
    fifteen = Node(15)
    """
                            1
                2                       3
            4  5  6               7     8          9
        10  11 12              13            14   15
    """

    one.children = [two, three]
    two.children = [four, five, six]
    three.children = [seven, eight, nine]
    four.children = [ten]
    five.children = [eleven]
    six.children = [twelve]
    seven.children = [thirteen]
    nine.children = [fourteen, fifteen]

    kt = KaryTree()
    kt.root = one

    fizzy_tree = fizz_buzz_tree(kt)

    actual = fizzy_tree.breadth_first()
    expected = [
        "1",
        "2",
        "Fizz",
        "4",
        "Buzz",
        "Fizz",
        "7",
        "8",
        "Fizz",
        "Buzz",
        "11",
        "Fizz",
        "13",
        "14",
        "FizzBuzz",
    ]

    assert actual == expected

    assert kt.breadth_first() == [
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
    ]
def test_create_node():
    one = Node(1)
    actual = one.value
    expected = 1
    assert actual == expected