[1346] | 1 | from unittest.case import TestCase
|
---|
| 2 | from tudelft.utilities.immutablelist.FixedList import FixedList
|
---|
| 3 | from tudelft.utilities.immutablelist.ImmutableList import ImmutableList
|
---|
| 4 | from tudelft.utilities.immutablelist.Repeat import Repeat
|
---|
| 5 |
|
---|
| 6 |
|
---|
| 7 | class 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 |
|
---|