def test_qsort(): assert qsort([]) == [] assert qsort([1]) == [1] assert qsort([2,3,1]) == [1,2,3] assert (qsort([9, 2, 5, 6, 7, 1, 8, 4, 3]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]) assert qsort(['c','b','a','d']) == ['a','b','c','d']
def test_qsort_core(self): sa = self.assertEqual if True: l = [3, 10, 2, 15, 4] sorting.qsort(l, 0, len(l)) sa(l, sorted(l)) l = [3, 2, -23] sorting.qsort(l, 0, len(l)) sa(l, sorted(l)) l = [7, 4, 2, -1] sorting.qsort(l, 0, len(l)) sa(l, sorted(l)) for i in range(1,100): sa = self.assertEqual l = self.random_list(random.randint(10,100)) sl = sorted(l) sorting.qsort(l, 0, len(l)) sa(sl, l)
def test_qsort_core(self): sa = self.assertEqual if True: l = [3, 10, 2, 15, 4] sorting.qsort(l, 0, len(l)) sa(l, sorted(l)) l = [3, 2, -23] sorting.qsort(l, 0, len(l)) sa(l, sorted(l)) l = [7, 4, 2, -1] sorting.qsort(l, 0, len(l)) sa(l, sorted(l)) for i in range(1, 100): sa = self.assertEqual l = self.random_list(random.randint(10, 100)) sl = sorted(l) sorting.qsort(l, 0, len(l)) sa(sl, l)
import sorting print sorting.qsort([10,9,8,7,6,5,4,3,2,1]) print sorting.qsort([1,2,3,4,5,6,7,8,9,10]) print sorting.qsort([6,7,8,9,10,1,2,3,4,5]) print sorting.select([10,9,8,7,6,5,4,3,2,1]) print sorting.select([1,2,3,4,5,6,7,8,9,10]) print sorting.select([6,7,8,9,10,1,2,3,4,5]) print sorting.bubble([10,9,8,7,6,5,4,3,2,1]) print sorting.bubble([1,2,3,4,5,6,7,8,9,10]) print sorting.bubble([6,7,8,9,10,1,2,3,4,5])