source: utilitiespy/test/immutablelist/PowersetTest.py@ 1358

Last change on this file since 1358 was 309, checked in by wouter, 3 years ago

#103 added PowerSet and SubList

File size: 962 bytes
RevLine 
[309]1import unittest
2
3from tudelft.utilities.immutablelist.FixedList import FixedList
4from tudelft.utilities.immutablelist.ImmutableList import ImmutableList
5from tudelft.utilities.immutablelist.PowerSet import PowerSet
6
7
8class PowersetTest(unittest.TestCase):
9 list1=FixedList[int] ([1, 2, 3])
10
11 #blabla
12 def test(self):
13 ps = PowerSet[int](self.list1)
14 self.assertEquals(8, ps.size())
15 # first element is empty
16 self.assertEqual(0, ps.get(0).size())
17 # last element is the full set
18 self._allElementsMatch(self.list1, ps.get(7))
19 self._allElementsMatch(FixedList[int]([1, 3]), ps.get(5))
20
21 def testOutOfBounds(self):
22 ps = PowerSet[int](self.list1)
23 self.assertRaises(IndexError, lambda: ps.get(8))
24
25 def _allElementsMatch(self, l1:ImmutableList[int] ,
26 l2:ImmutableList[int] ):
27 self.assertEqual(l1.size(), l2.size())
28 for i in range(l1.size()):
29 self.assertEqual(l1.get(i), l2.get(i))
30
31 def testPrint(self):
32 print(PowerSet(FixedList([1,2,3,4])))
Note: See TracBrowser for help on using the repository browser.