@@ -127,20 +127,34 @@ final class PartialSortTests: XCTestCase {
127
127
assertStability ( [ 1 , 1 , 1 , 2 , 5 , 7 , 3 , 6 , 2 , 5 , 7 , 3 , 6 ] , withPrefix: 6 )
128
128
assertStability ( [ 1 , 1 , 1 , 2 , 5 , 7 , 3 , 6 , 2 , 5 , 7 , 3 , 6 ] , withPrefix: 20 )
129
129
assertStability ( [ 1 , 1 , 1 , 2 , 5 , 7 , 3 , 6 , 2 , 5 , 7 , 3 , 6 ] , withPrefix: 1000 )
130
+ assertStability ( [ 0 , 0 , 0 , 0 , 0 ] , withPrefix: 0 )
131
+ assertStability ( [ 0 , 0 , 0 , 0 , 0 ] , withPrefix: 1 )
132
+ assertStability ( [ 0 , 0 , 0 , 0 , 0 ] , withPrefix: 2 )
133
+ assertStability ( [ 0 , 0 , 0 , 0 , 0 ] , withPrefix: 5 )
134
+ assertStability ( [ 0 , 0 ] , withPrefix: 1 )
135
+ assertStability ( [ 0 , 0 ] , withPrefix: 2 )
136
+ assertStability ( [ 0 , 1 , 0 , 1 , 0 , 1 ] , withPrefix: 2 )
137
+ assertStability ( [ 0 , 1 , 0 , 1 , 0 , 1 ] , withPrefix: 6 )
138
+ assertStability ( [ 0 , 0 , 0 , 1 , 1 , 1 ] , withPrefix: 1 )
139
+ assertStability ( [ 0 , 0 , 0 , 1 , 1 , 1 ] , withPrefix: 3 )
140
+ assertStability ( [ 0 , 0 , 0 , 1 , 1 , 1 ] , withPrefix: 4 )
141
+ assertStability ( [ 0 , 0 , 0 , 1 , 1 , 1 ] , withPrefix: 6 )
142
+ assertStability ( [ 1 , 1 , 1 , 0 , 0 , 0 ] , withPrefix: 1 )
143
+ assertStability ( [ 1 , 1 , 1 , 0 , 0 , 0 ] , withPrefix: 3 )
144
+ assertStability ( [ 1 , 1 , 1 , 0 , 0 , 0 ] , withPrefix: 4 )
145
+ assertStability ( [ 1 , 1 , 1 , 0 , 0 , 0 ] , withPrefix: 6 )
130
146
}
131
147
132
148
func assertStability(
133
149
_ actual: [ Int ] ,
134
- withPrefix prefixCount: Int ,
135
- file: StaticString = #file,
136
- line: UInt = #line
150
+ withPrefix prefixCount: Int
137
151
) {
138
152
let indexed = actual. enumerated ( )
139
- let sorted = indexed. map { $0 } . sortedPrefix ( prefixCount) { $0. element < $1. element }
153
+ let sorted = indexed. map { $0 } . sortedPrefix ( prefixCount) { $0. element < $1. element }
140
154
141
155
for element in Set ( actual) {
142
156
let filtered = sorted. filter { $0. element == element } . map ( \. offset)
143
157
XCTAssertEqual ( filtered, filtered. sorted ( ) )
144
- }
158
+ }
145
159
}
146
160
}
0 commit comments