import unittest from tudelft.utilities.immutablelist.FixedList import FixedList from tudelft.utilities.immutablelist.Outer import Outer class OuterTest (unittest.TestCase) : list1 = FixedList([ "a", "b" ]) list2 = FixedList([ "c", "d" ]) list3 = FixedList[str]([]) list4 = FixedList( [ "e" ]) list5 = FixedList([ "f", "g", "h" ]) list6 = FixedList([ "i" ]) def test(self): p = Outer([self.list1, self.list2]) self.assertEqual(4, p.size()) self.assertEqual("[['a', 'c'],['b', 'c'],['a', 'd'],['b', 'd']]", str(p)) print("data=" + str(p) ) def testEmpty(self): p = Outer([self.list1, self.list2, self.list3]) self.assertEqual(0, p.size()) def testEmpty2(self): p = Outer([]) self.assertEqual(0, p.size()); def test2(self): p = Outer([self.list1, self.list4]) self.assertEquals(2, p.size()) print("data=" + str(p) ) def test3(self): p = Outer([self.list1, self.list2, self.list5]) self.assertEqual(2 * 2 * 3, p.size()) print("data=" + str(p) ) self.assertEqual( "[['a', 'c', 'f'],['b', 'c', 'f'],['a', 'd', 'f'],['b', 'd', 'f'],['a', 'c', 'g'],['b', 'c', 'g'],['a', 'd', 'g'],['b', 'd', 'g'],['a', 'c', 'h'],['b', 'c', 'h'],['a', 'd', 'h'],['b', 'd', 'h']]", str(p)) def testSmall(self): p = Outer([self.list4, self.list6]) print("data=" + str(p) ) self.assertEqual(1, p.size()) self.assertEqual("[['e', 'i']]", str(p)) def testConstructors(self): p1 = Outer([self.list1, self.list2, self.list5]) p2 = Outer([self.list1, self.list2, self.list5]) self.assertEqual(p1, p2); self.assertEqual(hash(p1), hash(p2))