def test_empty_list(): ls = [] assert heapsort.hs(ls) == []
def test_sort_same_elements_out_as_put_in(ls): ls_out = heapsort.hs(ls) assert Counter(ls_out) == Counter(ls)
def test_sort_last_element_is_the_largest(ls): ls = heapsort.hs(ls) last = ls[-1] for i in range(0, len(ls)-1): assert last >= ls[i]
def test_sort_output_has_the_same_number_of_elements(ls): ls_out = heapsort.hs(ls) assert len(ls_out) == len(ls)
def test_sort_first_element_is_the_smallest(ls): ls = heapsort.hs(ls) first = ls[0] for i in range(1, len(ls)): assert first <= ls[i]