def test_get_child_no(self): node = Node(3) self.assertEqual(node._get_child_no(), 0) node._left = Node(1) self.assertEqual(node._get_child_no(), 1) node._right = Node(4) self.assertEqual(node._get_child_no(), 2)
def test_right_left_case(self): root = Node(15) root._color = NodeColor.BLACK root._left = Node(7) root._left._color = NodeColor.BLACK root._left._parent = root root._right = Node(25) root._right._color = NodeColor.RED root._right._parent = root self.assertListEqual([(7, NodeColor.BLACK), (15, NodeColor.BLACK), (25, NodeColor.RED)], root.get_inorder()) root.insert(24) root = root._parent self.assertListEqual([(7, NodeColor.BLACK), (15, NodeColor.RED), (24, NodeColor.BLACK), (25, NodeColor.RED)], root.get_inorder())