def test_put(self): ps = PowerSet() ps.put('abc') self.assertEqual(ps.size(), 1) ps.put('def') self.assertEqual(ps.size(), 2) ps.put('abc') self.assertEqual(ps.size(), 2) ps.put('abc') self.assertEqual(ps.size(), 2) ps.put('abc') self.assertEqual(ps.size(), 2) ps.put('naeekbnhha') self.assertEqual(ps.size(), 3) ps.put('fkmmeilabl') # slot is buzy self.assertEqual(ps.size(), 4) ps.put('pqbpdmhdkc') self.assertEqual(ps.size(), 5) ps.put('fnlmmnckdl') # slot is buzy self.assertEqual(ps.size(), 6) # print('\n', ps.get_slots()) slots = ps.get_slots() self.assertEqual(slots[13262], 'naeekbnhha') self.assertEqual(slots[13295], 'fkmmeilabl') self.assertEqual(slots[14490], 'pqbpdmhdkc') self.assertEqual(slots[14523], 'fnlmmnckdl')
def test_powerSetRemove(self): ps = PowerSet() ps.put(1) ps.put(-5) ps.put(13) ps.put(0) ps.put(4) self.assertEqual(ps.size(), 5) ps.remove(-5) self.assertEqual(ps.size(), 4) ps.remove(-5) self.assertEqual(ps.size(), 4)
def test_powerSetPutRemove(self): ps = PowerSet() ps.put(1) self.assertEqual(ps.size(), 1) ps.put(-11) self.assertEqual(ps.size(), 2) ps.remove(18) self.assertEqual(ps.size(), 2) ps.put(12) ps.put(-4) self.assertEqual(ps.size(), 4) ps.remove(12) self.assertEqual(ps.size(), 3)
def test_remove(self): ps = PowerSet() ps.put('abc') ps.put('def') ps.put('ghx') ps.put('cvb') self.assertEqual(ps.get('abc'), True) self.assertEqual(ps.get('def'), True) self.assertEqual(ps.get('ghx'), True) self.assertEqual(ps.get('cvb'), True) self.assertEqual(ps.remove('abc'), True) self.assertEqual(ps.get('abc'), False) self.assertEqual(ps.size(), 3) self.assertEqual(ps.remove('abc1'), False) self.assertEqual(ps.size(), 3) self.assertEqual(ps.remove('abc'), False) self.assertEqual(ps.size(), 3) self.assertEqual(ps.remove('def'), True) self.assertEqual(ps.get('def'), False) self.assertEqual(ps.size(), 2) self.assertEqual(ps.remove('ghx'), True) self.assertEqual(ps.get('ghx'), False) self.assertEqual(ps.size(), 1) self.assertEqual(ps.remove('cvb'), True) self.assertEqual(ps.get('cvb'), False) self.assertEqual(ps.size(), 0) self.assertEqual(ps.remove('111111'), False) self.assertEqual(ps.size(), 0) ps.put('cvb') self.assertEqual(ps.remove('cvb'), True) self.assertEqual(ps.get('cvb'), False) self.assertEqual(ps.size(), 0)
def test_powerSetPut(self): ps = PowerSet() ps.put(1) self.assertEqual(ps.size(), 1) ps.put(1) self.assertEqual(ps.size(), 1)
def test_powerSetRemoveFromEmptySet(self): ps = PowerSet() ps.remove(11) self.assertEqual(ps.size(), 0)