def test_update_extra_vals(node: Node): def compare(ind): return ind > 0 def update(e_val): return e_val + 1 node.update_extra_vals(compare, update) assert node.right.extra_vals == 2 assert node.extra_vals == 0 assert node.left.extra_vals == -1
def test_insert(node: Node): assert node.right is None and node.left is None, "no inserts can be made before this test" # right insert node.insert(1, 1) assert isinstance(node.right, Node) assert node.right.value == 1 # left insert node.insert(-1, -1) assert isinstance(node.left, Node) assert node.left.value == -1
def test_yx_vals(node: Node): yx_list = node.get_yx_vals([], 2, 2) assert yx_list[0] == [0, 1, 0] assert yx_list[1] == [1, 2, 1] assert yx_list[2] == [1, 0, -1]
def test_size(node: Node): assert node.get_size() == 3
def test_depth(node: Node): assert node.depth() == 2