def testSumListIntLists(self): lu = ListUser() lst = [range(4)] * 4 self.assertEqual(lu.sumListOfIntLists(lst), sum([sum(line) for line in [range(4)] * 4])) self.assertEqual(lu.callSumListOfIntLists(lst), sum([sum(line) for line in [range(4)] * 4]))
def testOredMinBoolList(self): lu = ListUser() lst = [False, False, True] self.assertTrue(lu.oredMinBoolList(lst)) self.assertTrue(lu.callOredMinBoolList(lst)) lst = [False, False, False] self.assertFalse(lu.oredMinBoolList(lst)) self.assertFalse(lu.callOredMinBoolList(lst))
def testCreateListOfIntLists(self): num = 4 lu = ListUser() lst = lu.createListOfIntLists(num) self.assertEqual(type(lst), list) self.assertEqual(len(lst), num) for i in lst: self.assertEqual(type(i), list) self.assertEqual(i, range(num)) for j in i: self.assertEqual(type(j), int) self.assertEqual(lst, [range(num)] * 4)
def testCreateListOfIntLists(self): num = 4 lu = ListUser() lst = lu.createListOfIntLists(num) self.assertEqual(type(lst), list) self.assertEqual(len(lst), num) for i in lst: self.assertEqual(type(i), list) self.assertEqual(i, list(range(num))) for j in i: self.assertEqual(type(j), int) self.assertEqual(lst, [list(range(num))] * 4)
def testCreateValList(self): num = 4 lu = ListUser() lst = lu.createValList(num) self.assertEqual(type(lst), list) self.assertEqual(len(lst), num) for i in lst: self.assertEqual(type(i), Val) self.assertEqual([val.valId() for val in lst], list(range(num))) lst = lu.callCreateValList(num) self.assertEqual(type(lst), list) self.assertEqual(len(lst), num) for i in lst: self.assertEqual(type(i), Val) self.assertEqual([val.valId() for val in lst], list(range(num)))
def testCreateIntList(self): num = 4 lu = ListUser() lst = lu.createIntList(num) self.assertEqual(type(lst), list) self.assertEqual(len(lst), num) for i in lst: self.assertEqual(type(i), int) self.assertEqual(lst, list(range(num))) lst = lu.callCreateIntList(num) self.assertEqual(type(lst), list) self.assertEqual(len(lst), num) for i in lst: self.assertEqual(type(i), int) self.assertEqual(lst, list(range(num)))
def testCreateIntList(self): num = 4 lu = ListUser() lst = lu.createIntList(num) self.assertEqual(type(lst), list) self.assertEqual(len(lst), num) for i in lst: self.assertEqual(type(i), int) self.assertEqual(lst, range(num)) lst = lu.callCreateIntList(num) self.assertEqual(type(lst), list) self.assertEqual(len(lst), num) for i in lst: self.assertEqual(type(i), int) self.assertEqual(lst, range(num))
def testCreateValList(self): num = 4 lu = ListUser() lst = lu.createValList(num) self.assertEqual(type(lst), list) self.assertEqual(len(lst), num) for i in lst: self.assertEqual(type(i), Val) self.assertEqual([val.valId() for val in lst], range(num)) lst = lu.callCreateValList(num) self.assertEqual(type(lst), list) self.assertEqual(len(lst), num) for i in lst: self.assertEqual(type(i), Val) self.assertEqual([val.valId() for val in lst], range(num))
def testCreateMinBoolList(self): lu = ListUser() lst = lu.createMinBoolList(True, False) self.assertEqual(type(lst), list) self.assertEqual(len(lst), 2) for i in lst: self.assertEqual(type(i), bool) self.assertEqual(lst, [True, False]) lst = lu.callCreateMinBoolList(False, True) self.assertEqual(type(lst), list) self.assertEqual(len(lst), 2) for i in lst: self.assertEqual(type(i), bool) self.assertEqual(lst, [False, True])
def testCreateObjList(self): o1 = Obj(1) o2 = Obj(2) lu = ListUser() lst = lu.createObjList(o1, o2) self.assertEqual(type(lst), list) self.assertEqual(len(lst), 2) for i in lst: self.assertEqual(type(i), Obj) self.assertEqual(lst, [o1, o2]) self.assertEqual([obj.objId() for obj in lst], [1, 2]) lst = lu.callCreateObjList(o1, o2) self.assertEqual(type(lst), list) self.assertEqual(len(lst), 2) for i in lst: self.assertEqual(type(i), Obj) self.assertEqual(lst, [o1, o2]) self.assertEqual([obj.objId() for obj in lst], [1, 2])
def testSumObjList(self): lu = ListUser() lst = [Obj(i) for i in range(4)] self.assertEqual(lu.sumObjList(lst), sum([obj.objId() for obj in lst])) self.assertEqual(lu.callSumObjList(lst), sum([obj.objId() for obj in lst]))
def testSumValList(self): lu = ListUser() lst = [Val(i) for i in range(4)] self.assertEqual(lu.sumValList(lst), sum([val.valId() for val in lst])) self.assertEqual(lu.callSumValList(lst), sum([val.valId() for val in lst]))
def __init__(self): ListUser.__init__(self)
def testSumObjList(self): lu = ListUser() lst = [Obj(i) for i in list(range(4))] self.assertEqual(lu.sumObjList(lst), sum([obj.objId() for obj in lst])) self.assertEqual(lu.callSumObjList(lst), sum([obj.objId() for obj in lst]))
def testSumIntList(self): lu = ListUser() lst = range(4) self.assertEqual(lu.sumIntList(lst), sum(lst)) self.assertEqual(lu.callSumIntList(lst), sum(lst))