Exemple #1
0
    def test_get(self):
        ps = PowerSet()

        self.assertEqual(ps.get('abc'), False)

        ps.put('abc')
        ps.put('def')
        ps.put('ghx')
        ps.put('cvb')

        self.assertEqual(ps.get('abc'), True)
        self.assertEqual(ps.get('abc1'), False)
        self.assertEqual(ps.get('def'), True)
        self.assertEqual(ps.get('ghx'), True)
        self.assertEqual(ps.get('cvb'), True)
Exemple #2
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)