def test_new_right_and_left(self): root = Node() root.set_root() right = root.new_right() left = root.new_left() self.assertEqual(right.sibling, left) self.assertEqual(left.sibling, right)
def test_new_left(self): root = Node() root.set_root() left = root.new_left() self.assertTrue(root.has_left()) self.assertFalse(root.has_right()) self.assertEqual(root.left, left) self.assertEqual(left.parent, root) self.assertFalse(root.is_leaf()) self.assertFalse(left.is_root()) self.assertTrue(left.is_leaf()) self.assertEqual('left', left.position)
def test_new_right(self): root = Node() root.set_root() right = root.new_right() self.assertTrue(root.has_right()) self.assertFalse(root.has_left()) self.assertEqual(root.right, right) self.assertEqual(right.parent, root) self.assertFalse(root.is_leaf()) self.assertFalse(right.is_root()) self.assertTrue(right.is_leaf()) self.assertEqual('right', right.position)
def test_set_left1(self): c = Node() c.set_root() plus = c.new_left() d = c.new_right() a = plus.new_left() b = plus.new_right() c.set_left(a) self.assertEqual('left', a.position) self.assertEqual(c.left, a) self.assertEqual(a.parent, c) self.assertEqual(a.sibling, d) self.assertEqual(d.sibling, a)
def test_set_right2(self): c = Node() c.set_root() d = c.new_left() plus = c.new_right() a = plus.new_left() b = plus.new_right() c.set_right(b) self.assertEqual('right', b.position) self.assertEqual(c.right, b) self.assertEqual(b.parent, c) self.assertEqual(b.sibling, d) self.assertEqual(d.sibling, b)
def test_set_root(self): node = Node() node.set_root() self.assertTrue(node.is_root()) self.assertEqual('root', node.position) self.assertTrue(node.is_leaf())