@@ -28,7 +28,8 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
2828 do {
2929 var dataset : [ ( Int , Double ) ] = [ ]
3030 for index in 1 ... 10 {
31- dataset. append ( ( index, Double ( index) ) )
31+ // make sure value is different from score so we can test we are getting the correct values
32+ dataset. append ( ( index + 100 , Double ( index) ) )
3233 }
3334
3435 _ = try connection. zadd ( dataset, to: SortedSetCommandsTests . testKey) . wait ( )
@@ -110,19 +111,19 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
110111
111112 func test_zrank( ) throws {
112113 let futures = [
113- connection. zrank ( of: 1 , in: key) ,
114- connection. zrank ( of: 2 , in: key) ,
115- connection. zrank ( of: 3 , in: key) ,
114+ connection. zrank ( of: 101 , in: key) ,
115+ connection. zrank ( of: 102 , in: key) ,
116+ connection. zrank ( of: 103 , in: key) ,
116117 ]
117118 let scores = try EventLoopFuture < Int ? > . whenAllSucceed ( futures, on: connection. eventLoop) . wait ( )
118119 XCTAssertEqual ( scores, [ 0 , 1 , 2 ] )
119120 }
120121
121122 func test_zrevrank( ) throws {
122123 let futures = [
123- connection. zrevrank ( of: 1 , in: key) ,
124- connection. zrevrank ( of: 2 , in: key) ,
125- connection. zrevrank ( of: 3 , in: key) ,
124+ connection. zrevrank ( of: 101 , in: key) ,
125+ connection. zrevrank ( of: 102 , in: key) ,
126+ connection. zrevrank ( of: 103 , in: key) ,
126127 ]
127128 let scores = try EventLoopFuture < Int ? > . whenAllSucceed ( futures, on: connection. eventLoop) . wait ( )
128129 XCTAssertEqual ( scores, [ 9 , 8 , 7 ] )
@@ -235,21 +236,21 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
235236 }
236237
237238 func test_zincrby( ) throws {
238- var score = try connection. zincrby ( 3_00_1398.328923 , element: 1 , in: key) . wait ( )
239+ var score = try connection. zincrby ( 3_00_1398.328923 , element: 101 , in: key) . wait ( )
239240 XCTAssertEqual ( score, 3_001_399.328923 )
240241
241- score = try connection. zincrby ( - 201_309.1397318 , element: 1 , in: key) . wait ( )
242+ score = try connection. zincrby ( - 201_309.1397318 , element: 101 , in: key) . wait ( )
242243 XCTAssertEqual ( score, 2_800_090.1891912 )
243244
244- score = try connection. zincrby ( 20 , element: 1 , in: key) . wait ( )
245+ score = try connection. zincrby ( 20 , element: 101 , in: key) . wait ( )
245246 XCTAssertEqual ( score, 2_800_110.1891912 )
246247 }
247248
248249 func test_zunionstore( ) throws {
249250 let testKey = RedisKey ( #function + #file)
250251
251- _ = try connection. zadd ( [ ( 1 , 1 ) , ( 2 , 2 ) ] , to: #function) . wait ( )
252- _ = try connection. zadd ( [ ( 3 , 3 ) , ( 4 , 4 ) ] , to: #file) . wait ( )
252+ _ = try connection. zadd ( [ ( 101 , 1 ) , ( 102 , 2 ) ] , to: #function) . wait ( )
253+ _ = try connection. zadd ( [ ( 103 , 3 ) , ( 104 , 4 ) ] , to: #file) . wait ( )
253254
254255 let unionCount = try connection. zunionstore (
255256 as: testKey,
@@ -258,14 +259,14 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
258259 aggregateMethod: . max
259260 ) . wait ( )
260261 XCTAssertEqual ( unionCount, 10 )
261- let rank = try connection. zrank ( of: 10 , in: testKey) . wait ( )
262+ let rank = try connection. zrank ( of: 110 , in: testKey) . wait ( )
262263 XCTAssertEqual ( rank, 9 )
263- let score = try connection. zscore ( of: 10 , in: testKey) . wait ( )
264+ let score = try connection. zscore ( of: 110 , in: testKey) . wait ( )
264265 XCTAssertEqual ( score, 30 )
265266 }
266267
267268 func test_zinterstore( ) throws {
268- _ = try connection. zadd ( [ ( 3 , 3 ) , ( 10 , 10 ) , ( 11 , 11 ) ] , to: #function) . wait ( )
269+ _ = try connection. zadd ( [ ( 103 , 3 ) , ( 110 , 10 ) , ( 111 , 11 ) ] , to: #function) . wait ( )
269270
270271 let unionCount = try connection. zinterstore (
271272 as: #file,
@@ -274,9 +275,9 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
274275 aggregateMethod: . min
275276 ) . wait ( )
276277 XCTAssertEqual ( unionCount, 2 )
277- let rank = try connection. zrank ( of: 10 , in: #file) . wait ( )
278+ let rank = try connection. zrank ( of: 110 , in: #file) . wait ( )
278279 XCTAssertEqual ( rank, 1 )
279- let score = try connection. zscore ( of: 10 , in: #file) . wait ( )
280+ let score = try connection. zscore ( of: 110 , in: #file) . wait ( )
280281 XCTAssertEqual ( score, 20.0 )
281282 }
282283
@@ -302,9 +303,9 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
302303 let values = try RedisConnection . _mapSortedSetResponse ( elements, scoreIsFirst: false )
303304 . map { ( value, _) in Int ( fromRESP: value) }
304305
305- XCTAssertEqual ( values [ 0 ] , 2 )
306- XCTAssertEqual ( values [ 1 ] , 3 )
307- XCTAssertEqual ( values [ 2 ] , 4 )
306+ XCTAssertEqual ( values [ 0 ] , 102 )
307+ XCTAssertEqual ( values [ 1 ] , 103 )
308+ XCTAssertEqual ( values [ 2 ] , 104 )
308309 }
309310
310311 func test_zrevrange( ) throws {
@@ -330,9 +331,9 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
330331 let values = try RedisConnection . _mapSortedSetResponse ( elements, scoreIsFirst: false )
331332 . map { ( value, _) in Int ( fromRESP: value) }
332333
333- XCTAssertEqual ( values [ 0 ] , 9 )
334- XCTAssertEqual ( values [ 1 ] , 8 )
335- XCTAssertEqual ( values [ 2 ] , 7 )
334+ XCTAssertEqual ( values [ 0 ] , 109 )
335+ XCTAssertEqual ( values [ 1 ] , 108 )
336+ XCTAssertEqual ( values [ 2 ] , 107 )
336337 }
337338
338339 func test_zrangebyscore( ) throws {
@@ -459,14 +460,14 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
459460 }
460461
461462 func test_zrem( ) throws {
462- var count = try connection. zrem ( 1 , from: key) . wait ( )
463+ var count = try connection. zrem ( 101 , from: key) . wait ( )
463464 XCTAssertEqual ( count, 1 )
464465 count = try connection. zrem ( [ 1 ] , from: key) . wait ( )
465466 XCTAssertEqual ( count, 0 )
466467
467- count = try connection. zrem ( 2 , 3 , 4 , 5 , from: key) . wait ( )
468+ count = try connection. zrem ( 102 , 103 , 104 , 105 , from: key) . wait ( )
468469 XCTAssertEqual ( count, 4 )
469- count = try connection. zrem ( [ 5 , 6 , 7 ] , from: key) . wait ( )
470+ count = try connection. zrem ( [ 105 , 106 , 107 ] , from: key) . wait ( )
470471 XCTAssertEqual ( count, 2 )
471472 }
472473
0 commit comments