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)
Exemple #3
0
    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_powerSetRemoveFromEmptySet(self):
     ps = PowerSet()
     ps.remove(11)
     self.assertEqual(ps.size(), 0)