@@ -39,6 +39,7 @@ enum EGeneric<T> {
39
39
}
40
40
extension EGeneric : Equatable where T: Equatable { }
41
41
extension EGeneric : Hashable where T: Hashable { }
42
+ extension EGeneric : Comparable where T: Comparable { }
42
43
43
44
enum NoValues {
44
45
case a, b, c
@@ -89,6 +90,19 @@ func testEquatableHashable<T: Equatable & Hashable>(cases: [Int: (T, T, Bool, Bo
89
90
" \( #file) : \( testLine) LHS < \( debugDescription ( lhs) ) .hashValue> ( \( lhsHash) ) == RHS < \( debugDescription ( rhs) ) .hashValue> ( \( rhsHash) ) doesn't match < \( hashEqual) > " )
90
91
}
91
92
}
93
+ func testEquatableHashableComparable< T: Hashable & Comparable > ( cases: [ Int : ( T , T , Bool , Bool , Bool ) ] ) {
94
+ for (testLine, ( lhs, rhs, equal, hashEqual, less) ) in cases {
95
+ expectEqual ( lhs == rhs, equal,
96
+ " \( #file) : \( testLine) LHS < \( debugDescription ( lhs) ) > == RHS < \( debugDescription ( rhs) ) > doesn't match < \( equal) > " )
97
+ expectEqual ( lhs < rhs, less,
98
+ " \( #file) : \( testLine) LHS < \( debugDescription ( lhs) ) > < RHS < \( debugDescription ( rhs) ) > doesn't match < \( less) > " )
99
+
100
+ let lhsHash = lhs. hashValue
101
+ let rhsHash = rhs. hashValue
102
+ expectEqual ( lhsHash == rhsHash, hashEqual,
103
+ " \( #file) : \( testLine) LHS < \( debugDescription ( lhs) ) .hashValue> ( \( lhsHash) ) == RHS < \( debugDescription ( rhs) ) .hashValue> ( \( rhsHash) ) doesn't match < \( hashEqual) > " )
104
+ }
105
+ }
92
106
93
107
class TestEquatableHashable : TestSuper {
94
108
lazy var int : [ Int : ( SInt , SInt , Bool , Bool ) ] = [
@@ -147,28 +161,28 @@ class TestEquatableHashable : TestSuper {
147
161
testEquatableHashable ( cases: generic)
148
162
}
149
163
150
- lazy var egeneric : [ Int : ( EGeneric < SInt > , EGeneric < SInt > , Bool , Bool ) ] = [
151
- #line : ( EGaOne, EGaOne, true , true ) ,
152
- #line : ( EGaOne, EGaTwo, false , false ) ,
153
- #line : ( EGaOne, EGbOne, false , false ) ,
154
- #line : ( EGaOne, EGbTwo, false , false ) ,
155
- #line : ( EGaOne, EGc___, false , false ) ,
156
-
157
- #line : ( EGbOne, EGaOne, false , false ) ,
158
- #line : ( EGbOne, EGaTwo, false , false ) ,
159
- #line : ( EGbOne, EGbOne, true , true ) ,
160
- #line : ( EGbOne, EGbTwo, false , false ) ,
161
- #line : ( EGbOne, EGc___, false , false ) ,
162
-
163
- #line : ( EGc___, EGaOne, false , false ) ,
164
- #line : ( EGc___, EGaTwo, false , false ) ,
165
- #line : ( EGc___, EGbOne, false , false ) ,
166
- #line : ( EGc___, EGbTwo, false , false ) ,
167
- #line : ( EGc___, EGc___, true , true ) ,
164
+ lazy var egeneric : [ Int : ( EGeneric < SInt > , EGeneric < SInt > , Bool , Bool , Bool ) ] = [
165
+ #line : ( EGaOne, EGaOne, true , true , false ) ,
166
+ #line : ( EGaOne, EGaTwo, false , false , true ) ,
167
+ #line : ( EGaOne, EGbOne, false , false , true ) ,
168
+ #line : ( EGaOne, EGbTwo, false , false , true ) ,
169
+ #line : ( EGaOne, EGc___, false , false , true ) ,
170
+
171
+ #line : ( EGbOne, EGaOne, false , false , false ) ,
172
+ #line : ( EGbOne, EGaTwo, false , false , false ) ,
173
+ #line : ( EGbOne, EGbOne, true , true , false ) ,
174
+ #line : ( EGbOne, EGbTwo, false , false , true ) ,
175
+ #line : ( EGbOne, EGc___, false , false , true ) ,
176
+
177
+ #line : ( EGc___, EGaOne, false , false , false ) ,
178
+ #line : ( EGc___, EGaTwo, false , false , false ) ,
179
+ #line : ( EGc___, EGbOne, false , false , false ) ,
180
+ #line : ( EGc___, EGbTwo, false , false , false ) ,
181
+ #line : ( EGc___, EGc___, true , true , false ) ,
168
182
]
169
183
170
184
func test_EGeneric( ) {
171
- testEquatableHashable ( cases: egeneric)
185
+ testEquatableHashableComparable ( cases: egeneric)
172
186
}
173
187
}
174
188
0 commit comments