def test_union_empty(self): s = PowerSet() s2 = PowerSet() result = s.union(s2) self.assertEqual(result.size(), 0)
def setUp(self): self.set_1 = PowerSet() self.set_1.put("AA") self.set_1.put("Bc") self.set_1.put("dE") self.set_1.put("eD") self.set_2 = PowerSet() self.set_2.put("AA") self.set_2.put("BB") self.set_2.put("dE") self.set_2.put("DD")
def test_difference_empty(self): s = PowerSet() s2 = PowerSet() s.put('One') s.put('Two') s.put('Three') s2.put('One') s2.put('Two') s2.put('Three') result = s.difference(s2) self.assertEqual(result.size(), 0)
def test_union(self): s = PowerSet() s2 = PowerSet() s.put('One') s.put('Two') s.put('Three') s2.put('Four') s2.put('Five') s2.put('Six') result = s.union(s2) self.assertEqual(result.size(), 6)
def test_intersection_non_empty(self): s = PowerSet() s2 = PowerSet() s.put('One') s.put('Two') s.put('Three') s2.put('One') s2.put('Five') s2.put('Six') result = s.intersection(s2) self.assertEqual(result.size(), 1)
def test_issubset(self): self.assertEqual(self.set_1.issubset(self.set_2), False) self.set_3 = PowerSet() self.set_3.put("AA") self.set_3.put("dE") self.assertEqual(self.set_1.issubset(self.set_3), True)
def test_intersection(self): self.assertEqual( self.set_1.intersection(self.set_2).slots, [None, ['dE'], None, None, ['AA'], None, None]) self.set_2 = PowerSet() self.set_2.put('EE') self.set_2.put('DD') self.assertEqual( self.set_1.intersection(self.set_2).slots, [None, None, None, None, None, None, None]) self.set_2 = PowerSet() self.assertEqual( self.set_1.intersection(self.set_2).slots, [None, None, None, None, None, None, None])
def test_put(self): s = PowerSet() s.put('One') self.assertEqual(s.get('One'), True) s.put('One') self.assertEqual(s.get('One'), True)
def test_issubset(self): s = PowerSet() s2 = PowerSet() s3 = PowerSet() s.put('One') s.put('Two') s.put('Three') s2.put('One') s2.put('Two') s3.put('Four') s3.put('Five') self.assertEqual(s.issubset(s2), True) self.assertEqual(s.issubset(s3), False)
def test_remove(self): s = PowerSet() s.put('One') self.assertEqual(s.get('One'), True) s.remove('One') self.assertEqual(s.get('One'), False)
def test_union(self): self.assertEqual( self.set_1.union(self.set_2).slots, [None, ['dE', 'eD'], None, ['DD'], ['AA', 'Bc'], None, ['BB']]) self.set_2 = PowerSet() self.assertEqual( self.set_1.union(self.set_2).slots, [None, ['dE', 'eD'], None, None, ['AA', 'Bc'], None, None]) self.set_1 = PowerSet() self.set_2 = PowerSet() self.set_2.put("AA") self.set_2.put("Bc") self.set_2.put("dE") self.set_2.put("eD") self.assertEqual( self.set_1.union(self.set_2).slots, [None, ['dE', 'eD'], None, None, ['AA', 'Bc'], None, None])
def test_put(self): self.set_1 = PowerSet() self.assertEqual(self.set_1.slots, [None, None, None, None, None, None, None]) self.set_1.put("AA") self.set_1.put("Bc") self.set_1.put("dE") self.set_1.put("eD") self.assertEqual( self.set_1.slots, [None, ['dE', 'eD'], None, None, ['AA', 'Bc'], None, None]) self.set_1.put("AA") self.set_1.put("Bc") self.set_1.put("dE") self.set_1.put("eD") self.assertEqual( self.set_1.slots, [None, ['dE', 'eD'], None, None, ['AA', 'Bc'], None, None])