def test_init_with_list_of_tuples(self):
     bst = BinarySearchTree([(2, 'B'), (1, 'A'), (3, 'C')])
     assert bst.root.data == (2, 'B')
     assert bst.root.left.data == (1, 'A')
     assert bst.root.right.data == (3, 'C')
     assert bst.size == 3
     assert bst.is_empty() is False
 def test_init_with_list_of_strings(self):
     bst = BinarySearchTree(['B', 'A', 'C'])
     assert bst.root.data == 'B'
     assert bst.root.left.data == 'A'
     assert bst.root.right.data == 'C'
     assert bst.size == 3
     assert bst.is_empty() is False
 def test_init_with_list(self):
     bst = BinarySearchTree([2, 1, 3])
     assert bst.root.data == 2
     assert bst.root.left.data == 1
     assert bst.root.right.data == 3
     assert bst.size == 3
     assert bst.is_empty() is False
 def test_init(self):
     bst = BinarySearchTree()
     assert bst.root is None
     assert bst.size == 0
     assert bst.is_empty() is True
 def test_tree_creation(self):
     bst = BinarySearchTree()
     self.assertEqual(len(bst), 0)
     self.assertTrue(bst.is_empty())
Example #6
0
 def test_init(self):
     tree = BinarySearchTree()
     assert tree.root is None
     assert tree.size == 0
     assert tree.is_empty() is True