def test_set_root(self): t1 = BinaryTree("cedar") t1.key = "oak" self.assertEquals(t1.key, "oak") t1.set_root("maple") self.assertEquals(t1.key, "maple") t1.set_root(100) self.assertEquals(t1.key, 100)
def test_BinaryTree(self): # Check if you can make a new node of different types, or change types t1 = BinaryTree("maple") self.assertEquals(t1.key, "maple") t1.key = "oak" self.assertEquals(t1.key, "oak") t1.key = 0 self.assertEquals(t1.key, 0) t1.key = [1, 2, 3] self.assertEquals(t1.key, [1, 2, 3]) t2 = BinaryTree(0) self.assertEquals(t2.key, 0) t3 = BinaryTree([]) self.assertEquals(t3.key, []) # Check that you can set the nodes t1.lc = "left leaf" t1.rc = "right leaf" self.assertEquals(t1.lc, "left leaf") self.assertEquals(t1.rc, "right leaf")