def test_sort_time_compare(self): t1 = timeit.Timer( lambda: integer_sort.insertion_sort(self._BIG_DATA)).timeit(1) t2 = timeit.Timer( lambda: integer_sort.merge_sort(self._BIG_DATA)).timeit(1) self.assertGreater(t1, t2)
def test_sort_time_compare(self): t1 = timeit.Timer(lambda: integer_sort.insertion_sort(self._BIG_DATA)).timeit(1) t2 = timeit.Timer(lambda: integer_sort.merge_sort(self._BIG_DATA)).timeit(1) self.assertGreater(t1, t2)
def test_merge_sort_big_data(self): self.assertEquals(integer_sort.merge_sort(self._BIG_DATA), sorted(self._BIG_DATA))
def test_merge_sort_input_data_was_not_changed(self): data = self._SMALL_DATA[:] integer_sort.merge_sort(data) self.assertEquals(data, self._SMALL_DATA)
def test_merge_sort_small_data(self): data = self._SMALL_DATA[:] self.assertEquals(integer_sort.merge_sort(data), sorted(self._SMALL_DATA)) self.assertEquals(data, self._SMALL_DATA)
def test_merge_sort_same_data(self): self.assertEquals(integer_sort.merge_sort([1, 1, 1, 1]), [1, 1, 1, 1])
def test_merge_sort_one_item(self): self.assertEquals(integer_sort.merge_sort([1]), [1])
def test_merge_sort_empty_list(self): data = [] new_data = integer_sort.merge_sort(data) self.assertEquals(new_data, []) self.assertIsNot(data, new_data)
def test_merge_sort_return_type(self): self.assertIsInstance(integer_sort.merge_sort([]), list)