예제 #1
0
 def test_heap_sort(self):
     """测试堆排序"""
     sort_result = binary_heap.heap_sort(list([0, 1, 2, 3, 4, 5, 6, 7]))
     self.assertListEqual(sort_result, list([7, 6, 5, 4, 3, 2, 1, 0]))
예제 #2
0
 def test_reverse_sort_array2(self):
     self.assertEqual(
         [16, 14, 10, 9, 8, 7, 4, 3, 2, 1],
         heap_sort(data=self.array2, reverse=True)
     )
예제 #3
0
 def test_sorted_value_of_array2(self):
     self.assertEqual(
         [1, 2, 3, 4, 7, 8, 9, 10, 14, 16],
         heap_sort(self.array2)
     )
예제 #4
0
 def test_reverse_sort_array1(self):
     self.assertEqual(
         [11, 8, 6, 4, 3], heap_sort(data=self.array1, reverse=True)
     )
예제 #5
0
 def test_sorted_value_of_array1(self):
     self.assertEqual([3, 4, 6, 8, 11], heap_sort(self.array1))