source: utilitiespy/test/immutablelist/SubListTest.py@ 1404

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

#103 added PowerSet and SubList

File size: 1.1 KB
RevLine 
[309]1import unittest
2from tudelft.utilities.immutablelist.FixedList import FixedList
3from tudelft.utilities.immutablelist.SubList import SubList
4
5
6class SubListTest(unittest.TestCase):
7 list3 = FixedList[int]([1, 2, 3]);
8
9 select0 = 0
10 select1 = 1
11 select6 = 6
12
13 def testSubList1(self):
14 # element ONE means binary 001 means SubList contains only 1.
15 l1 = SubList[int]( self.list3, self.select1)
16 print(l1)
17 self.assertEqual(1, l1.size())
18 self.assertEqual(1, l1.get(0))
19
20 def testSubList6(self):
21 # SIX = 110 so element 2 and 3 selected
22 l1 = SubList[int](self.list3, self.select6)
23 print(l1)
24 self.assertEqual(2, l1.size())
25 self.assertEqual(2, l1.get(0))
26
27 def testOutOfRangeIndex(self):
28 # SIX = 110 so element 2 and 3 selected
29 l1 = SubList[int](self.list3, self.select6)
30 self.assertRaises(IndexError, lambda:l1.get(2))
31
32 def testEmptySubList(self):
33 l1 = SubList[int](self.list3, self.select0)
34 print(l1)
35 self.assertEqual(0, l1.size())
36
37 def testComplement(self):
38 l1 = SubList[int](self.list3, self.select1)
39 l1 = l1.complement()
40 self.assertEquals(2, l1.size())
41 print(l1)
Note: See TracBrowser for help on using the repository browser.