def test_partition_str_two_same_repeating(): arr = ['test3', 'test3', 'test3', 'test2', 'test2', 'test2'] part_index = qsort._partition(arr, 0, 5, 4) assert part_index == 2 assert arr == ['test2', 'test2', 'test2', 'test3', 'test3', 'test3']
def test_partition_str_end_of_arr(): with pytest.raises(qsort.InvalidBoundError): arr = ['a', 'z', 'g', 'b', 'q'] qsort._partition(arr, 5, 5, 5)
def test_parttion_str_all_same_value(): arr = [ 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test' ] assert qsort._partition(arr, 0, 10, 0) == 10
def test_parttion_str_out_of_bound_neg(): with pytest.raises(qsort.InvalidBoundError): qsort._partition(['test', 'test2', 'test'], -2, 2, 3)
def test_parttion_str_only_one(): assert qsort._partition(['test'], 0, 0, 0) == 0
def test_parttion_str_only_two(): arr = ['test2', 'test1'] assert qsort._partition(arr, 0, 1, 0) == 1
def test_partion_two_same_repeating(): arr = [3, 3, 3, 2, 2, 2] part_index = qsort._partition(arr, 0, 5, 4) assert part_index == 2 assert arr == [2, 2, 2, 3, 3, 3]
def test_partition_num_end_of_arr(): with pytest.raises(qsort.InvalidBoundError): arr = [9, 85, 58, 1, 5] qsort._partition(arr, 5, 5, 5)
def test_parttion_num_out_of_bound_neg(): with pytest.raises(qsort.InvalidBoundError): qsort._partition([0, 2, 0], -2, 2, 3)
def test_parttion_num_all_same_value(): arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2] assert qsort._partition(arr, 0, 10, 0) == 10
def test_partition_num_only_two(): arr = [2, 1] assert qsort._partition(arr, 0, 1, 0) == 1
def test_partition_num_only_one(): assert qsort._partition([1], 0, 0, 0) == 0
def test_partition_empty_arr(): with pytest.raises(qsort.InvalidBoundError): qsort._partition([], 0, 0, 0) == 0