Exemple #1
0
 def testMostCommon_withMultipleElements(self):
     common_value = 8
     array = [
         common_value, 5, 1, 1, common_value, 5, 5, common_value,
         common_value
     ]
     actual = ArrayUtility.most_common(array)
     self.assertEqual(common_value, actual)
Exemple #2
0
 def test_count_occurrence_whenValueDoesNotExist(self):
     value_to_evaluate = 7
     expected = 0
     array1 = [1, 6]
     array2 = [9, 8, 11]
     actual = ArrayUtility.count_occurrence(array1, array2,
                                            value_to_evaluate)
     self.assertEqual(expected, actual)
Exemple #3
0
 def count_occurrence_whenValueExistInSecondArray(self):
     value_to_evaluate = 9
     expected = 2
     array1 = [1, 6]
     array2 = [value_to_evaluate, value_to_evaluate, 3]
     actual = ArrayUtility.count_occurrence(array1, array2,
                                            value_to_evaluate)
     self.assertEqual(expected, actual)
Exemple #4
0
 def count_occurrence_whenValueExistInFirstArray(self):
     value_to_evaluate = 7
     expected = 1
     array1 = [1, 6, value_to_evaluate]
     array2 = [3]
     actual = ArrayUtility.count_occurrence(array1, array2,
                                            value_to_evaluate)
     self.assertEqual(expected, actual)
Exemple #5
0
 def count_occurrence_whenValueAppearsInBoth(self):
     value_to_evaluate = 7
     expected = 7
     array1 = [
         value_to_evaluate, 1, value_to_evaluate, 8, 84, 5,
         value_to_evaluate, 9, 8, value_to_evaluate
     ]
     array2 = [
         1, value_to_evaluate, value_to_evaluate, 8, 5, value_to_evaluate,
         91
     ]
     actual = ArrayUtility.count_occurrence(array1, array2,
                                            value_to_evaluate)
     self.assertEqual(expected, actual)
Exemple #6
0
 def test_rotate_left_for_one(self):
     array = [5, 1, 8, 4, 2]
     expected = [1, 8, 4, 2, 5]
     actual = ArrayUtility.rotate(array, 1)
     self.assertEqual(expected, actual)
Exemple #7
0
 def testMostCommon_withOnlyOneElement(self):
     array = [5]
     expected = 5
     actual = ArrayUtility.most_common(array)
     self.assertEqual(expected, actual)
Exemple #8
0
 def util(self, array1, array2, expected):
     actual = ArrayUtility.merge(array1, array2)
     self.assertEqual(expected, actual)
Exemple #9
0
 def test_rotate_left_for_more_than_one(self):
     array = [5, 1, 8, 4, 2]
     expected = [4, 2, 5, 1, 8]
     actual = ArrayUtility.rotate(array, 3)
     self.assertEqual(expected, actual)