@@ -792,4 +792,30 @@ class ListRRCMethodsTests: TestCase {
792
792
array. replaceSubrange ( subrange, with: newElements)
793
793
compare ( array: array, with: list)
794
794
}
795
+
796
+ func testRealmListOfStringsComparison( ) {
797
+ // Lists made from identical arrays should be equal:
798
+ let strings = [ " a " , " b " , " c " ]
799
+ let list1 = List < String > ( )
800
+ list1. append ( objectsIn: strings)
801
+
802
+ let list2 = List < String > ( )
803
+ list2. append ( objectsIn: strings)
804
+
805
+ XCTAssertTrue ( list1 !== list2, " instances should not be identical " )
806
+ XCTAssertTrue ( list1 == list2, " instances should be equal by `==` operator " )
807
+ XCTAssertTrue ( list1. isEqual ( list2) , " instances should be equal by `isEqual` method " )
808
+ XCTAssertTrue ( Array ( list1) == Array ( list2) , " instances converted to Swift.Array should be equal " )
809
+
810
+ // Lists made from different-length arrays should not be equal,
811
+ // even if the common elements are equal.
812
+ let strings2 = [ " a " , " b " , " c " , " d " ]
813
+ let list3 = List < String > ( )
814
+ list3. append ( objectsIn: strings2)
815
+
816
+ XCTAssertTrue ( list1 !== list3, " instances should not be identical " )
817
+ XCTAssertFalse ( list1 == list3, " instances should not be equal by `==` operator " )
818
+ XCTAssertFalse ( list1. isEqual ( list3) , " instances should not be equal by `isEqual` method " )
819
+ XCTAssertFalse ( Array ( list1) == Array ( list3) , " instances converted to Swift.Array should not be equal " )
820
+ }
795
821
}
0 commit comments