39
39
* Class SortTest
40
40
*/
41
41
class SortTest extends TestCase {
42
- public function testBubbleSort () {
42
+
43
+ public function testBubbleSort (): void {
43
44
$ bubbleSort = new BubbleSort ();
44
- $ result = $ bubbleSort ->sort ([12 , 40 , 9 , 55 , 1 , 13 ]);
45
+ $ result = $ bubbleSort ->sort ([12 , 40 , 9 , 55 , 1 , 13 ]);
45
46
$ this ->assertTrue ($ result === [1 , 9 , 12 , 13 , 40 , 55 ]);
46
47
47
48
$ result = $ bubbleSort ->sort ([]);
@@ -51,9 +52,9 @@ public function testBubbleSort() {
51
52
$ this ->assertTrue ($ result === [9 ]);
52
53
}
53
54
54
- public function testSelectionSort () {
55
+ public function testSelectionSort (): void {
55
56
$ selectionSort = new SelectionSort ();
56
- $ result = $ selectionSort ->sort ([12 , 40 , 9 , 55 , 1 , 13 ]);
57
+ $ result = $ selectionSort ->sort ([12 , 40 , 9 , 55 , 1 , 13 ]);
57
58
$ this ->assertTrue ($ result === [1 , 9 , 12 , 13 , 40 , 55 ]);
58
59
59
60
$ result = $ selectionSort ->sort ([]);
@@ -63,10 +64,10 @@ public function testSelectionSort() {
63
64
$ this ->assertTrue ($ result === [9 ]);
64
65
}
65
66
66
- public function testMergeSort () {
67
+ public function testMergeSort (): void {
67
68
$ mergeSort = new MergeSort ();
68
- $ arr = [12 , 40 , 9 , 55 , 1 , 13 ];
69
- $ result = $ mergeSort ->sort ($ arr );
69
+ $ arr = [12 , 40 , 9 , 55 , 1 , 13 ];
70
+ $ result = $ mergeSort ->sort ($ arr );
70
71
$ this ->assertTrue ($ result === [1 , 9 , 12 , 13 , 40 , 55 ]);
71
72
72
73
$ result = $ mergeSort ->sort ([]);
@@ -76,10 +77,10 @@ public function testMergeSort() {
76
77
$ this ->assertTrue ($ result === [9 ]);
77
78
}
78
79
79
- public function testInsertionSort () {
80
+ public function testInsertionSort (): void {
80
81
$ insertionSort = new InsertionSort ();
81
- $ arr = [12 , 40 , 9 , 55 , 1 , 13 ];
82
- $ result = $ insertionSort ->sort ($ arr );
82
+ $ arr = [12 , 40 , 9 , 55 , 1 , 13 ];
83
+ $ result = $ insertionSort ->sort ($ arr );
83
84
$ this ->assertTrue ($ result === [1 , 9 , 12 , 13 , 40 , 55 ]);
84
85
85
86
$ result = $ insertionSort ->sort ([]);
@@ -89,56 +90,56 @@ public function testInsertionSort() {
89
90
$ this ->assertTrue ($ result === [9 ]);
90
91
}
91
92
92
- public function testTimSort () {
93
+ public function testTimSort (): void {
93
94
94
95
$ timSort = new TimSort ();
95
- $ arr = [12 , 40 , 9 , 55 , 1 , 13 ];
96
- $ result = $ timSort ->sort ($ arr );
96
+ $ arr = [12 , 40 , 9 , 55 , 1 , 13 ];
97
+ $ result = $ timSort ->sort ($ arr );
97
98
$ this ->assertTrue ($ result === [1 , 9 , 12 , 13 , 40 , 55 ]);
98
99
99
- $ arr = [5 , 21 , 7 , 23 , 19 ];
100
+ $ arr = [5 , 21 , 7 , 23 , 19 ];
100
101
$ result = $ timSort ->sort ($ arr );
101
102
$ this ->assertTrue ($ result === [5 , 7 , 19 , 21 , 23 ]);
102
103
103
- $ arr = [2 , 3 , 1 , 5 , 6 , 7 ];
104
+ $ arr = [2 , 3 , 1 , 5 , 6 , 7 ];
104
105
$ result = $ timSort ->sort ($ arr );
105
106
$ this ->assertTrue ($ result === [1 , 2 , 3 , 5 , 6 , 7 ]);
106
107
107
- $ arr = [];
108
+ $ arr = [];
108
109
$ result = $ timSort ->sort ($ arr );
109
110
$ this ->assertTrue ($ result === []);
110
111
111
- $ arr = [1 ];
112
+ $ arr = [1 ];
112
113
$ result = $ timSort ->sort ($ arr );
113
114
$ this ->assertTrue ($ result === [1 ]);
114
115
}
115
116
116
- public function testQuickSort () {
117
+ public function testQuickSort (): void {
117
118
$ quickSort = new QuickSort ();
118
- $ arr = [12 , 40 , 9 , 55 , 1 , 13 ];
119
- $ result = $ quickSort ->sort ($ arr );
119
+ $ arr = [12 , 40 , 9 , 55 , 1 , 13 ];
120
+ $ result = $ quickSort ->sort ($ arr );
120
121
$ this ->assertTrue ($ result === [1 , 9 , 12 , 13 , 40 , 55 ]);
121
122
122
- $ arr = [5 , 21 , 7 , 23 , 19 ];
123
+ $ arr = [5 , 21 , 7 , 23 , 19 ];
123
124
$ result = $ quickSort ->sort ($ arr );
124
125
$ this ->assertTrue ($ result === [5 , 7 , 19 , 21 , 23 ]);
125
126
126
- $ arr = [2 , 3 , 1 , 5 , 6 , 7 ];
127
+ $ arr = [2 , 3 , 1 , 5 , 6 , 7 ];
127
128
$ result = $ quickSort ->sort ($ arr );
128
129
$ this ->assertTrue ($ result === [1 , 2 , 3 , 5 , 6 , 7 ]);
129
130
130
- $ arr = [];
131
+ $ arr = [];
131
132
$ result = $ quickSort ->sort ($ arr );
132
133
$ this ->assertTrue ($ result === []);
133
134
134
- $ arr = [1 ];
135
+ $ arr = [1 ];
135
136
$ result = $ quickSort ->sort ($ arr );
136
137
$ this ->assertTrue ($ result === [1 ]);
137
138
}
138
139
139
- public function testRadixSort () {
140
+ public function testRadixSort (): void {
140
141
$ radixSort = new RadixSort ();
141
- $ result = $ radixSort ->sort ([12 , 40 , 9 , 55 , 1 , 13 ]);
142
+ $ result = $ radixSort ->sort ([12 , 40 , 9 , 55 , 1 , 13 ]);
142
143
$ this ->assertTrue ($ result === [1 , 9 , 12 , 13 , 40 , 55 ]);
143
144
144
145
$ result = $ radixSort ->sort ([]);
@@ -147,4 +148,5 @@ public function testRadixSort() {
147
148
$ result = $ radixSort ->sort ([9 ]);
148
149
$ this ->assertTrue ($ result === [9 ]);
149
150
}
151
+
150
152
}
0 commit comments