def test_powerSetIntersectionEmpty(self): ps = PowerSet() ps1 = PowerSet() ps1.put(-5) ps1.put(9) ps1.put(1) ps1.put(11) ps1.put(131) psIntersection = ps.intersection(ps1) self.assertEqual(psIntersection.size(), 0) ps1 = PowerSet() psIntersection = ps.intersection(ps1) self.assertEqual(psIntersection.size(), 0)
def test_powerSetIntersectionHundredsElements(self): ps = PowerSet() ps1 = PowerSet() for i in range(1, 101): ps.put(i) for i in range(50, 151): ps1.put(i) psIntersection = ps.intersection(ps1) self.assertEqual(psIntersection.size(), 51)
def test_powerSetIntersectionManyElements(self): ps = PowerSet() ps1 = PowerSet() for i in range(1, 10001): ps.put(i) for i in range(9900, 20001): ps1.put(i) start_time = time.time() psIntersection = ps.intersection(ps1) self.assertEqual(psIntersection.size(), 101) print('time to processing', time.time() - start_time)
def test_powerSetIntersection(self): ps = PowerSet() ps.put(1) ps.put(-5) ps.put(13) ps.put(0) ps.put(4) ps.put(9) ps.put(92) ps.put(131) ps.put(11) ps.put(18) ps1 = PowerSet() ps1.put(-5) ps1.put(9) ps1.put(1) ps1.put(11) ps1.put(131) psIntersection = ps.intersection(ps1) self.assertEqual(psIntersection.size(), 5) ps1 = PowerSet() ps1.put(-5) psIntersection = ps.intersection(ps1) self.assertEqual(psIntersection.size(), 1) ps1 = PowerSet() ps1.put(999) ps1.put(1000) ps1.put(111) ps1.put(22222) psIntersection = ps.intersection(ps1) self.assertEqual(psIntersection.size(), 0) ps1 = PowerSet() psIntersection = ps.intersection(ps1) self.assertEqual(psIntersection.size(), 0)