Пример #1
0
def test_empty_list():
    ls = []
    assert heapsort.hs(ls) == []
Пример #2
0
def test_sort_same_elements_out_as_put_in(ls):
    ls_out = heapsort.hs(ls)
    assert Counter(ls_out) == Counter(ls)
Пример #3
0
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]
Пример #4
0
def test_sort_output_has_the_same_number_of_elements(ls):
    ls_out = heapsort.hs(ls)
    assert len(ls_out) == len(ls)
Пример #5
0
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]