Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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)
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
 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())