source: utilitiespy/test/immutablelist/RepeatTest.py@ 1356

Last change on this file since 1356 was 1346, checked in by wouter, 5 days ago

#407 added Repeat to test.

File size: 993 bytes
Line 
1from unittest.case import TestCase
2from tudelft.utilities.immutablelist.FixedList import FixedList
3from tudelft.utilities.immutablelist.ImmutableList import ImmutableList
4from tudelft.utilities.immutablelist.Repeat import Repeat
5
6
7class RepeatTest (TestCase):
8
9 def __init__(self, name):
10 super().__init__(name)
11 self.__lst: ImmutableList[int] = FixedList([0, 1, 2, 3, 4])
12
13 def testHeadTail(self):
14 l:Repeat = Repeat(self.__lst, 3, True)
15 self.assertEquals(15, l.size())
16 for n in range(5):
17 self.assertEquals(n, l.get(n))
18 self.assertEquals(n, l.get(n + 5))
19 self.assertEquals(n, l.get(n + 10))
20
21
22 def testMerged(self):
23 l:Repeat = Repeat(self.__lst, 3, False)
24 self.assertEquals(15, l.size())
25 for n in range(5):
26 self.assertEquals(n, l.get(3 * n))
27 self.assertEquals(n, l.get(3 * n + 1))
28 self.assertEquals(n, l.get(3 * n + 2))
29
30 def testboundarytest(self):
31 l:Repeat = Repeat(self.__lst, 3, True)
32 self.assertRaises(IndexError,lambda:l.get(16)) # out of range
33
Note: See TracBrowser for help on using the repository browser.