Beispiel #1
0
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']
Beispiel #2
0
def test_partition_str_end_of_arr():
    with pytest.raises(qsort.InvalidBoundError):
        arr = ['a', 'z', 'g', 'b', 'q']
        qsort._partition(arr, 5, 5, 5)
Beispiel #3
0
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
Beispiel #4
0
def test_parttion_str_out_of_bound_neg():
    with pytest.raises(qsort.InvalidBoundError):
        qsort._partition(['test', 'test2', 'test'], -2, 2, 3)
Beispiel #5
0
def test_parttion_str_only_one():
    assert qsort._partition(['test'], 0, 0, 0) == 0
Beispiel #6
0
def test_parttion_str_only_two():
    arr = ['test2', 'test1']
    assert qsort._partition(arr, 0, 1, 0) == 1
Beispiel #7
0
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]
Beispiel #8
0
def test_partition_num_end_of_arr():
    with pytest.raises(qsort.InvalidBoundError):
        arr = [9, 85, 58, 1, 5]
        qsort._partition(arr, 5, 5, 5)
Beispiel #9
0
def test_parttion_num_out_of_bound_neg():
    with pytest.raises(qsort.InvalidBoundError):
        qsort._partition([0, 2, 0], -2, 2, 3)
Beispiel #10
0
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
Beispiel #11
0
def test_partition_num_only_two():
    arr = [2, 1]
    assert qsort._partition(arr, 0, 1, 0) == 1
Beispiel #12
0
def test_partition_num_only_one():
    assert qsort._partition([1], 0, 0, 0) == 0
Beispiel #13
0
def test_partition_empty_arr():
    with pytest.raises(qsort.InvalidBoundError):
        qsort._partition([], 0, 0, 0) == 0