from unittest.case import TestCase from tudelft.utilities.immutablelist.FixedList import FixedList from tudelft.utilities.immutablelist.ImmutableList import ImmutableList from tudelft.utilities.immutablelist.Repeat import Repeat class RepeatTest (TestCase): def __init__(self, name): super().__init__(name) self.__lst: ImmutableList[int] = FixedList([0, 1, 2, 3, 4]) def testHeadTail(self): l:Repeat = Repeat(self.__lst, 3, True) self.assertEquals(15, l.size()) for n in range(5): self.assertEquals(n, l.get(n)) self.assertEquals(n, l.get(n + 5)) self.assertEquals(n, l.get(n + 10)) def testMerged(self): l:Repeat = Repeat(self.__lst, 3, False) self.assertEquals(15, l.size()) for n in range(5): self.assertEquals(n, l.get(3 * n)) self.assertEquals(n, l.get(3 * n + 1)) self.assertEquals(n, l.get(3 * n + 2)) def testboundarytest(self): l:Repeat = Repeat(self.__lst, 3, True) self.assertRaises(IndexError,lambda:l.get(16)) # out of range