@@ -512,3 +512,55 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
512
512
XCTAssertEqual ( count, 1 )
513
513
}
514
514
}
515
+
516
+ // MARK: - #104 zrevrange & zrange bug
517
+
518
+ extension SortedSetCommandsTests {
519
+ func test_zrange_realworld( ) throws {
520
+ struct Keys {
521
+ static let first = " 1E4FD2C5-C32E-4E3F-91B3-45478BCF0185 "
522
+ static let second = " 1E4FD2C5-C32E-4E3F-91B3-45478BCF0186 "
523
+ static let third = " 1E4FD2C5-C32E-4E3F-91B3-45478BCF0187 "
524
+ static let fourth = " 1E4FD2C5-C32E-4E3F-91B3-45478BCF0188 "
525
+ static let fifth = " 1E4FD2C5-C32E-4E3F-91B3-45478BCF0189 "
526
+ }
527
+ _ = try self . connection. send ( . zadd( [
528
+ ( Keys . first, 1 ) ,
529
+ ( Keys . second, 1 ) ,
530
+ ( Keys . third, 1 ) ,
531
+ ( Keys . fourth, 1 ) ,
532
+ ( Keys . fifth, 1 ) ,
533
+ ] , to: #function) ) . wait ( )
534
+
535
+ let elements = try self . connection. send ( . zrange( from: #function, fromIndex: 0 , returning: . valuesOnly) )
536
+ . wait ( )
537
+ . compactMap ( \. string)
538
+
539
+ XCTAssertEqual ( elements. count, 5 )
540
+ XCTAssertEqual ( elements, elements. sorted ( by: < ) )
541
+ }
542
+
543
+ func test_zrevrange_realworld( ) throws {
544
+ struct Keys {
545
+ static let first = " 1E4FD2C5-C32E-4E3F-91B3-45478BCF0185 "
546
+ static let second = " 1E4FD2C5-C32E-4E3F-91B3-45478BCF0186 "
547
+ static let third = " 1E4FD2C5-C32E-4E3F-91B3-45478BCF0187 "
548
+ static let fourth = " 1E4FD2C5-C32E-4E3F-91B3-45478BCF0188 "
549
+ static let fifth = " 1E4FD2C5-C32E-4E3F-91B3-45478BCF0189 "
550
+ }
551
+ _ = try self . connection. send ( . zadd( [
552
+ ( Keys . first, 1 ) ,
553
+ ( Keys . second, 1 ) ,
554
+ ( Keys . third, 1 ) ,
555
+ ( Keys . fourth, 1 ) ,
556
+ ( Keys . fifth, 1 ) ,
557
+ ] , to: #function) ) . wait ( )
558
+
559
+ let elements = try self . connection. send ( . zrevrange( from: #function, fromIndex: 0 , returning: . valuesOnly) )
560
+ . wait ( )
561
+ . compactMap ( \. string)
562
+
563
+ XCTAssertEqual ( elements. count, 5 )
564
+ XCTAssertEqual ( elements, elements. sorted ( by: > ) )
565
+ }
566
+ }
0 commit comments