Exemplo n.º 1
0
def test_inserting_root_and_two_children_then_right_child_should_be_red():
    object_under_test = RedBlackTree()
    object_under_test.insert(15)
    object_under_test.insert(8)
    object_under_test.insert(33)

    assert object_under_test.get_root().right.is_red is True
Exemplo n.º 2
0
def test_inserting_three_nodes_in_descending_line_then_root_should_be_black():
    object_under_test = RedBlackTree()
    object_under_test.insert(3)
    object_under_test.insert(2)
    object_under_test.insert(1)

    assert object_under_test.get_root().is_red is False
Exemplo n.º 3
0
def test_inserting_three_nodes_in_ascending_line_then_right_child_value_should_be_highest(
):
    object_under_test = RedBlackTree()
    object_under_test.insert(1)
    object_under_test.insert(2)
    object_under_test.insert(3)

    assert object_under_test.get_root().right.value == 3
Exemplo n.º 4
0
def test_inserting_three_nodes_in_ascending_line_then_root_value_should_be_in_the_middle(
):
    object_under_test = RedBlackTree()
    object_under_test.insert(1)
    object_under_test.insert(2)
    object_under_test.insert(3)

    assert object_under_test.get_root().value == 2
Exemplo n.º 5
0
def test_inserting_root_and_two_children_then_right_child_value_should_be_highest(
):
    object_under_test = RedBlackTree()
    object_under_test.insert(15)
    object_under_test.insert(8)
    object_under_test.insert(33)

    assert object_under_test.get_root().right.value == 33
Exemplo n.º 6
0
def test_inserting_root_and_two_children_then_root_value_should_be_in_the_middle(
):
    object_under_test = RedBlackTree()
    object_under_test.insert(2)
    object_under_test.insert(1)
    object_under_test.insert(3)

    assert object_under_test.get_root().value == 2
Exemplo n.º 7
0
def test_inserting_three_nodes_in_descending_line_then_right_child_should_be_red(
):
    object_under_test = RedBlackTree()
    object_under_test.insert(3)
    object_under_test.insert(2)
    object_under_test.insert(1)

    assert object_under_test.get_root().right.is_red is True
Exemplo n.º 8
0
def test_inserting_three_nodes_in_descending_line_then_left_child_value_should_be_lowest(
):
    object_under_test = RedBlackTree()
    object_under_test.insert(3)
    object_under_test.insert(2)
    object_under_test.insert(1)

    assert object_under_test.get_root().left.value == 1