示例#1
0
    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)
示例#2
0
    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)
示例#3
0
 def test_merge_sort_big_data(self):
     self.assertEquals(integer_sort.merge_sort(self._BIG_DATA), sorted(self._BIG_DATA))
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
 def test_merge_sort_same_data(self):
     self.assertEquals(integer_sort.merge_sort([1, 1, 1, 1]), [1, 1, 1, 1])
示例#7
0
 def test_merge_sort_one_item(self):
     self.assertEquals(integer_sort.merge_sort([1]), [1])
示例#8
0
 def test_merge_sort_empty_list(self):
     data = []
     new_data = integer_sort.merge_sort(data)
     self.assertEquals(new_data, [])
     self.assertIsNot(data, new_data)
示例#9
0
 def test_merge_sort_return_type(self):
     self.assertIsInstance(integer_sort.merge_sort([]), list)
示例#10
0
 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)
示例#11
0
 def test_merge_sort_big_data(self):
     self.assertEquals(integer_sort.merge_sort(self._BIG_DATA),
                       sorted(self._BIG_DATA))
示例#12
0
 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)
示例#13
0
 def test_merge_sort_same_data(self):
     self.assertEquals(integer_sort.merge_sort([1, 1, 1, 1]), [1, 1, 1, 1])
示例#14
0
 def test_merge_sort_one_item(self):
     self.assertEquals(integer_sort.merge_sort([1]), [1])
示例#15
0
 def test_merge_sort_empty_list(self):
     data = []
     new_data = integer_sort.merge_sort(data)
     self.assertEquals(new_data, [])
     self.assertIsNot(data, new_data)
示例#16
0
 def test_merge_sort_return_type(self):
     self.assertIsInstance(integer_sort.merge_sort([]), list)