[314] | 1 | import unittest
|
---|
| 2 | from tudelft.utilities.immutablelist.FixedList import FixedList
|
---|
| 3 | from unitpy.GeneralTests import GeneralTests
|
---|
| 4 | from tudelft.utilities.immutablelist.JoinedList import JoinedList
|
---|
| 5 | from typing import List
|
---|
| 6 |
|
---|
| 7 | class JoinedListTest(unittest.TestCase, GeneralTests[JoinedList[int]]):
|
---|
| 8 | l1 = FixedList[int]([1])
|
---|
| 9 | l1a = FixedList([1])
|
---|
| 10 | l2 = FixedList([2])
|
---|
| 11 |
|
---|
| 12 | join1 = JoinedList([l1, l1])
|
---|
| 13 | join1a = JoinedList([l1, l1a])
|
---|
| 14 | join2 = JoinedList([l1, l2])
|
---|
| 15 | join3 = JoinedList([l2, l1])
|
---|
| 16 |
|
---|
| 17 | #Override
|
---|
| 18 | def getGeneralTestData(self) -> List[List[JoinedList[int]]] :
|
---|
| 19 | return [[self.join1, self.join1a], [self.join2], [self.join3]]
|
---|
| 20 |
|
---|
| 21 | #Override
|
---|
| 22 | def getGeneralTestStrings(self)->List[str] :
|
---|
| 23 | return ["\\[1,1\\]", "\\[1,2\\]", "\\[2,1\\]"]
|
---|
| 24 |
|
---|
| 25 | def testGet(self) :
|
---|
| 26 | self.assertEqual( 2, self.join3.get(0))
|
---|
| 27 | self.assertEqual(1, self.join3.get(1))
|
---|
| 28 |
|
---|
| 29 | def testSize(self):
|
---|
| 30 | self.assertEqual(2, self.join3.size())
|
---|
| 31 |
|
---|
| 32 | def testWith(self):
|
---|
| 33 | join = self.join1.With(self.l2)
|
---|
| 34 | self.assertEqual(3, join.size())
|
---|
| 35 | self.assertEqual(2, join.get(2))
|
---|