Пример #1
0
 def test_multiple_leaf(self):
     """ Tree of single item. """
     a = BinarySearchTree()
     a[7] = 'Harry'
     a[8] = 'Ron'
     a.put(4, 'Hermione')
     a[9] = 'Ginny'
     self.assertFalse(a._get(7, a.root).isLeaf())
Пример #2
0
    def test_simple_parent(self):
        """ Check parent. """
        a = BinarySearchTree(7, 'Harry')
        a[8] = 'Ron'
	self.assertTrue(a._get(8, a.root).parent.value == 'Harry')
Пример #3
0
    def test_is_root(self):
        """ Check if root node is identified correctly. """
        a = BinarySearchTree(7, 'Harry')
        a[8] = 'Ron'
	self.assertTrue(a.root.isRoot())
	self.assertFalse(a._get(8, a.root).isRoot())