@@ -1240,6 +1240,36 @@ class TestIndexSet : XCTestCase {
1240
1240
}
1241
1241
}
1242
1242
1243
+ func testHashValue( ) throws {
1244
+ var sample1 = IndexSet ( )
1245
+ sample1. insert ( integersIn: 1 ..< 2 )
1246
+ sample1. insert ( integersIn: 100 ..< 200 )
1247
+ sample1. insert ( integersIn: 1000 ..< 2000 )
1248
+
1249
+ var sample2 = IndexSet ( )
1250
+ sample2. insert ( integersIn: 1 ..< 2 )
1251
+ sample2. insert ( integersIn: 100 ..< 200 )
1252
+ sample2. insert ( integersIn: 1000 ..< 2000 )
1253
+
1254
+ XCTAssertEqual ( sample1. hashValue, sample2. hashValue)
1255
+
1256
+ let sample3 = IndexSet ( [ 3 , 5 , 6 , 7 , 9 ] )
1257
+ let sample4 = IndexSet ( [ 3 , 5 , 6 , 7 , 9 ] )
1258
+ XCTAssertEqual ( sample3. hashValue, sample4. hashValue)
1259
+
1260
+ let sample5 = IndexSet ( [ 100 , NSNotFound - 1 , 200 ] )
1261
+ let sample6 = IndexSet ( [ 100 , NSNotFound - 1 , 200 ] )
1262
+ XCTAssertEqual ( sample5. hashValue, sample6. hashValue)
1263
+
1264
+ let sample7 = IndexSet ( integer: NSNotFound - 1 )
1265
+ let sample8 = IndexSet ( integer: NSNotFound - 1 )
1266
+ XCTAssertEqual ( sample7. hashValue, sample8. hashValue)
1267
+
1268
+ let sample9 = IndexSet ( )
1269
+ let sample10 = IndexSet ( )
1270
+ XCTAssertEqual ( sample9. hashValue, sample10. hashValue)
1271
+ }
1272
+
1243
1273
static var allTests : [ ( String , ( TestIndexSet ) -> ( ) throws -> Void ) ] {
1244
1274
return [
1245
1275
( " test_BasicConstruction " , test_BasicConstruction) ,
@@ -1288,6 +1318,7 @@ class TestIndexSet : XCTestCase {
1288
1318
( " testRemoveSplitting " , testRemoveSplitting) ,
1289
1319
( " testCodingRoundtrip " , testCodingRoundtrip) ,
1290
1320
( " testLoadedValuesMatch " , testLoadedValuesMatch) ,
1321
+ ( " testHashValue " , testHashValue) ,
1291
1322
]
1292
1323
}
1293
1324
0 commit comments