[309] | 1 | import unittest
|
---|
| 2 |
|
---|
| 3 | from tudelft.utilities.immutablelist.FixedList import FixedList
|
---|
| 4 | from tudelft.utilities.immutablelist.ImmutableList import ImmutableList
|
---|
| 5 | from tudelft.utilities.immutablelist.PowerSet import PowerSet
|
---|
| 6 |
|
---|
| 7 |
|
---|
| 8 | class 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]))) |
---|