|
1 |
| -# import alla sorting algoritms |
| 1 | +# Import folder where sorting algorithms |
| 2 | +import sys |
| 3 | +sys.path.append('../../Algorithms/sorting') |
| 4 | + |
| 5 | +# from bubblesort import bubblesort |
| 6 | + |
| 7 | +from bubblesort import bubblesort |
2 | 8 |
|
3 | 9 | L1 = [1,2,3,4,5,6,7,8,9]
|
4 |
| -L1_sorted = [] |
| 10 | +L1_sorted = sorted(L1) |
| 11 | + |
5 | 12 | L2 = [9,8,7,6,5,4,3,2,1]
|
6 |
| -L2_sorted = [] |
| 13 | +L2_sorted = sorted(L2) |
| 14 | + |
7 | 15 | L3 = [1,1,1,1,1,1,1,1,1]
|
8 |
| -L3_sorted = [] |
| 16 | +L3_sorted = sorted(L3) |
| 17 | + |
9 | 18 | L4 = [6,7,3,5,1,3]
|
10 |
| -L4_sorted = [1,3,3,5,6,7] |
| 19 | +L4_sorted = sorted(L4) |
| 20 | + |
11 | 21 | L5 = []
|
12 | 22 | L5_sorted = []
|
13 | 23 |
|
14 | 24 |
|
15 | 25 | # Bubblesort
|
16 |
| -assert sorted(L4) == L4_sorted, "Not correctly sorted" |
17 |
| -assert sorted(L4) == L4_sorted, "Not correctly sorted" |
18 |
| -assert sorted(L4) == L4_sorted, "Not correctly sorted" |
19 |
| -assert sorted(L4) == L4_sorted, "Not correctly sorted" |
20 |
| -assert sorted(L4) == L4_sorted, "Not correctly sorted" |
| 26 | +def test_bubblesort(): |
| 27 | + assert bubblesort(L1) == L1_sorted, "Not correctly sorted" |
| 28 | + assert bubblesort(L4) == L4_sorted, "Not correctly sorted" |
| 29 | + assert bubblesort(L4) == L4_sorted, "Not correctly sorted" |
| 30 | + assert bubblesort(L4) == L4_sorted, "Not correctly sorted" |
| 31 | + assert bubblesort(L4) == L4_sorted, "Not correctly sorted" |
21 | 32 |
|
22 | 33 | # Selectionsort
|
23 |
| -assert sorted(L4) == L4_sorted, "Not correctly sorted" |
24 |
| -assert sorted(L4) == L4_sorted, "Not correctly sorted" |
25 |
| -assert sorted(L4) == L4_sorted, "Not correctly sorted" |
26 |
| -assert sorted(L4) == L4_sorted, "Not correctly sorted" |
27 |
| -assert sorted(L4) == L4_sorted, "Not correctly sorted" |
| 34 | +# assert sorted(L4) == L4_sorted, "Not correctly sorted" |
| 35 | +# assert sorted(L4) == L4_sorted, "Not correctly sorted" |
| 36 | +# assert sorted(L4) == L4_sorted, "Not correctly sorted" |
| 37 | +# assert sorted(L4) == L4_sorted, "Not correctly sorted" |
| 38 | +# assert sorted(L4) == L4_sorted, "Not correctly sorted" |
28 | 39 |
|
29 | 40 | # Heapsort
|
30 | 41 |
|
|
0 commit comments