def linearmap_test(): #test init function M1 = Map() #test length function print len(M1) for k in range(16): v = chr(k + 65) #test add funct M1.add(k, v) print len(M1) #test valueOf() func for k in range(16): print 'value of {} is '.format(k), M1.valueOf(k) #print M1.valueOf(16) #test in for k in range(17): if k in M1: print '{} is in the Map'.format(k) else: print '{} is not the Map'.format(k) # test keyArray func keyArr = M1.keyArray() print "keyArray" for i in range(len(keyArr)): print keyArr[i] #print M1._entryList print "test remove funct" for k in range(16): #test remove funct M1.remove(k) print len(M1)
def test_iter(self): map = Map() map.add(1, 1) map.add(2, 2) print() for entry in map: print(entry) print("iterator succeed")
def test_remove(self): map = Map() map.add(1, 1) self.assertEqual(map.valueOf(1), 1) map.remove(1)
def test_contains(self): map = Map() map.add(1, 1) self.assertEqual(map.__contains__(1), True)
def test__findPosition(self): map = Map() map.add(1, 1) self.assertEqual(map._findPosition(1), 0)
def test_add(self): map = Map() map.add(1,1) self.assertEqual(len(map), 1)