import unittest from tudelft.utilities.immutablelist.FixedList import FixedList from tudelft.utilities.immutablelist.ImmutableList import ImmutableList from tudelft.utilities.immutablelist.PowerSet import PowerSet class PowersetTest(unittest.TestCase): list1=FixedList[int] ([1, 2, 3]) #blabla def test(self): ps = PowerSet[int](self.list1) self.assertEquals(8, ps.size()) # first element is empty self.assertEqual(0, ps.get(0).size()) # last element is the full set self._allElementsMatch(self.list1, ps.get(7)) self._allElementsMatch(FixedList[int]([1, 3]), ps.get(5)) def testOutOfBounds(self): ps = PowerSet[int](self.list1) self.assertRaises(IndexError, lambda: ps.get(8)) def _allElementsMatch(self, l1:ImmutableList[int] , l2:ImmutableList[int] ): self.assertEqual(l1.size(), l2.size()) for i in range(l1.size()): self.assertEqual(l1.get(i), l2.get(i)) def testPrint(self): print(PowerSet(FixedList([1,2,3,4])))