source: utilitiespy/test/immutablelist/OuterTest.py@ 1031

Last change on this file since 1031 was 285, checked in by wouter, 3 years ago

#97 added Outer and FixedList plus tests. Version now 1.0.1

File size: 1.7 KB
RevLine 
[285]1import unittest
2from tudelft.utilities.immutablelist.FixedList import FixedList
3from tudelft.utilities.immutablelist.Outer import Outer
4
5class OuterTest (unittest.TestCase) :
6 list1 = FixedList([ "a", "b" ])
7 list2 = FixedList([ "c", "d" ])
8 list3 = FixedList[str]([])
9 list4 = FixedList( [ "e" ])
10 list5 = FixedList([ "f", "g", "h" ])
11 list6 = FixedList([ "i" ])
12
13 def test(self):
14 p = Outer([self.list1, self.list2])
15 self.assertEqual(4, p.size())
16 self.assertEqual("[['a', 'c'],['b', 'c'],['a', 'd'],['b', 'd']]", str(p))
17 print("data=" + str(p) )
18
19 def testEmpty(self):
20 p = Outer([self.list1, self.list2, self.list3])
21 self.assertEqual(0, p.size())
22
23 def testEmpty2(self):
24 p = Outer([])
25 self.assertEqual(0, p.size());
26
27
28 def test2(self):
29 p = Outer([self.list1, self.list4])
30 self.assertEquals(2, p.size())
31 print("data=" + str(p) )
32
33 def test3(self):
34 p = Outer([self.list1, self.list2, self.list5])
35 self.assertEqual(2 * 2 * 3, p.size())
36 print("data=" + str(p) )
37 self.assertEqual(
38 "[['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']]",
39 str(p))
40
41 def testSmall(self):
42 p = Outer([self.list4, self.list6])
43 print("data=" + str(p) )
44 self.assertEqual(1, p.size())
45 self.assertEqual("[['e', 'i']]", str(p))
46
47 def testConstructors(self):
48 p1 = Outer([self.list1, self.list2, self.list5])
49 p2 = Outer([self.list1, self.list2, self.list5])
50 self.assertEqual(p1, p2);
51 self.assertEqual(hash(p1), hash(p2))
52
Note: See TracBrowser for help on using the repository browser.