12
12
//
13
13
// RUN: %target-run-simple-swift(-parse-as-library)
14
14
// REQUIRES: executable_test
15
- // REQUIRES: reflection
16
- // UNSUPPORTED: use_os_stdlib
17
15
// END.
18
16
//
19
17
//===----------------------------------------------------------------------===//
@@ -27,6 +25,7 @@ final class FlattenDistanceFromToTests {
27
25
let tests = FlattenDistanceFromToTests ( )
28
26
let suite = TestSuite ( " FlattenDistanceFromToTests " )
29
27
suite. test ( " EachIndexPair " , tests. testEachIndexPair)
28
+ suite. test ( " MinMaxOutputs " , tests. testMinMaxOutputs)
30
29
runAllTests ( )
31
30
}
32
31
}
@@ -142,3 +141,34 @@ extension FlattenDistanceFromToTests {
142
141
expectEqual ( invocations, 2502 , " unexpected workload " )
143
142
}
144
143
}
144
+
145
+ //===----------------------------------------------------------------------===//
146
+ // MARK: - Min Max Outputs
147
+ //===----------------------------------------------------------------------===//
148
+
149
+ extension FlattenDistanceFromToTests {
150
+
151
+ /// Checks some `Int.min` and `Int.max` distances.
152
+ ///
153
+ /// - Note: A distance of `Int.min` requires more than `Int.max` elements.
154
+ ///
155
+ func testMinMaxOutputs( ) {
156
+ for s : FlattenSequence in [
157
+
158
+ [ - 1 ..< Int . max/ 1 ] ,
159
+ [ 00 ..< Int . max/ 1 , 00 ..< 000000001 ] ,
160
+ [ 00 ..< 000000001 , 01 ..< Int . max/ 1 , 00 ..< 000000001 ] ,
161
+ [ 00 ..< 000000001 , 00 ..< Int . max/ 2 , 00 ..< Int . max/ 2 , 00 ..< 000000001 ]
162
+
163
+ ] . map ( { $0. joined ( ) } ) {
164
+
165
+ let a = s. startIndex, b = s. endIndex
166
+
167
+ expectEqual ( Int . min, s. distance ( from: b, to: s. index ( a, offsetBy: 00 ) ) )
168
+ expectEqual ( Int . max, s. distance ( from: s. index ( a, offsetBy: 01 ) , to: b) )
169
+
170
+ expectEqual ( Int . min, s. distance ( from: s. index ( b, offsetBy: 00 ) , to: a) )
171
+ expectEqual ( Int . max, s. distance ( from: a, to: s. index ( b, offsetBy: - 1 ) ) )
172
+ }
173
+ }
174
+ }
0 commit comments