Exemplo n.º 1
0
 def testK_mixedTypeElements(self):
     self.assertEqual(
         getCommonElements(['ba', 'a', 3, 2, 'k', 'c'], ['a', 2, 'l', 'c']),
         ['a', 2, 'c'])
     self.assertEqual(
         getCommonElements(['ba', 'a', [1, 2, 3], 2, 'k', 'c'],
                           ['a', 2, [1, 2, 3], 'l', 'c']),
         ['a', [1, 2, 3], 2, 'c'])
     print("+ Test testK_mixedTypeElements Passed")
Exemplo n.º 2
0
 def testI_listsWithRepeatedElements(self):
     self.assertEqual(getCommonElements([1, 1, 2, 2, 3, 3], [1, 2, 2, 3]),
                      [1, 2, 3])
     self.assertEqual(getCommonElements([1, 2, 2, 3], [1, 1, 2, 2, 3, 3]),
                      [1, 2, 3])
     print("+ Test testH_invalidEntries Passed")
Exemplo n.º 3
0
 def testJ_randomListsReceived(self):
     lists = generateRandomLists()
     self.assertTrue(isinstance(getCommonElements(lists[0], lists[1]),
                                list))
     print("+ Test testJ_randomListsReceived Passed")
Exemplo n.º 4
0
 def testG_unOrderedLists(self):
     self.assertEqual(getCommonElements([5, 3, 6, 1, 23, 2], [3, 1, 2]),
                      [3, 1, 2])
     self.assertEqual(getCommonElements([3, 1, 2], [5, 3, 6, 1, 23, 2]),
                      [3, 1, 2])
     print("+ Test testG_unOrderedLists Passed")
Exemplo n.º 5
0
 def testH_invalidEntries(self):
     with self.assertRaises(Exception) as context:
         getCommonElements(1, "s")
         getCommonElements([1, 2], [1, 2, 3])
     self.assertTrue(context.exception)
     print("+ Test testH_invalidEntries Passed")
Exemplo n.º 6
0
 def testE_secondListEmpty(self):
     self.assertEqual(getCommonElements([1, 2, 3], []), [])
     print("+ Test testE_secondListEmpty Passed")
Exemplo n.º 7
0
 def testF_bothListsEmpty(self):
     self.assertEqual(getCommonElements([], []), [])
     print("+ Test testF_bothListsEmpty Passed")
Exemplo n.º 8
0
 def testD_firstListEmtpy(self):
     self.assertEqual(getCommonElements([], [1, 2, 3]), [])
     print("+ Test test_firstListEmtpy Passed")
Exemplo n.º 9
0
 def testC_secondListLarger(self):
     self.assertEqual(getCommonElements([1, 2, 3], [1, 2, 3, 4]), [1, 2, 3])
     print("+ Test test_secondListLarger Passed")
Exemplo n.º 10
0
 def testB_firstListLarger(self):
     self.assertEqual(getCommonElements([1, 2, 3, 4], [1, 2, 3]), [1, 2, 3])
     print("+ Test test_firstListLarger Passed")
Exemplo n.º 11
0
 def testA_orderedLists(self):
     self.assertEqual(getCommonElements([1, 2, 3], [1, 2, 3]), [1, 2, 3])
     """Documentation for a method."""
     print(".+ Test test_orderedLists Passed")
Exemplo n.º 12
0

from list_confusion import getCommonElements
from list_confusion import generateRandomLists
import random

#Lists
#a = [1,1,2,3,4,8,13,21,34,55,89]
#b = [1,2,3,4,5,6,7,8,9,10,11,12,13]


print("-"*30)
print("List of common items:")

print(getCommonElements(random.sample(range(random.randrange(30,35)),random.randrange(10)),random.sample(range(random.randrange(30,35)),random.randrange(10))))