Esempio n. 1
0
 def test_missing_entries(self):
     list1 = find_missing([1, 2], [1, 2, 5])
     list2 = find_missing([4, 6, 8], [4, 6, 8, 10])
     list3 = find_missing([5, 4, 7, 6, 11, 66], [5, 4, 1, 7, 6, 11, 66])
     self.assertListEqual([5, 10, 1],
                          [list1, list2, list3],
                          msg='should return the missing number for lists with similar entries and a missing number')
Esempio n. 2
0
 def test_same_entries(self):
     list1 = find_missing([2], [2])
     list2 = find_missing([4], [4])
     list3 = find_missing([7], [7])
     self.assertListEqual([0, 0, 0],
                          [list1, list2, list3],
                          msg='should return 0 for lists with the same entries')
Esempio n. 3
0
 def test_100_range(self):
     big_range = [
         0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
         19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
         36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
         53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 65, 66, 67, 68, 69, 70,
         71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
         88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
     ]
     random.shuffle(big_range)
     self.assertEqual(find_missing(big_range), 64)
Esempio n. 4
0
def test():
    vals = list(range(10)) + list(range(11, 20))

    val = missing.find_missing(vals)
    assert val == 10
Esempio n. 5
0
 def test_ordered(self):
     self.assertEqual(find_missing([0, 1, 2, 3, 4, 5, 7]), 6)
Esempio n. 6
0
 def test_huge_range_shuffled(self):
     huge_range = list(range(1000))
     random.shuffle(list(huge_range))
     missing = huge_range.pop(random.randint(0, 999))
     self.assertEqual(find_missing(huge_range), missing)
Esempio n. 7
0
 def test_small_unordered(self):
     self.assertEqual(find_missing([3, 0, 1]), 2)
Esempio n. 8
0
 def test_minimal(self):
     self.assertEqual(find_missing([0]), 1)
Esempio n. 9
0
 def test_empty(self):
     self.assertEqual(find_missing([]), 0)
Esempio n. 10
0
 def test_empty_list(self):
     self.assertEqual(0, find_missing([], []),
                      msg='should return 0 for empty list')