mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Actually slice things in _StringGutsSlice
This commit is contained in:
@@ -157,6 +157,28 @@ func checkStringComparison(
|
||||
expectEqual(expected.isGE(), lhs >= rhs, stackTrace: stackTrace)
|
||||
expectEqual(expected.isGT(), lhs > rhs, stackTrace: stackTrace)
|
||||
checkComparable(expected, lhs, rhs, stackTrace: stackTrace.withCurrentLoc())
|
||||
|
||||
// Substring / Substring
|
||||
// Matching slices of != Strings may still be ==, but not vice versa
|
||||
if expected.isEQ() {
|
||||
for i in 0 ..< Swift.min(lhs.count, rhs.count) {
|
||||
let lhsSub = lhs.dropFirst(i)
|
||||
let rhsSub = rhs.dropFirst(i)
|
||||
|
||||
expectEqual(expected.isEQ(), lhsSub == rhsSub, stackTrace: stackTrace)
|
||||
expectEqual(expected.isNE(), lhsSub != rhsSub, stackTrace: stackTrace)
|
||||
checkHashable(
|
||||
expectedEqual: expected.isEQ(),
|
||||
lhs, rhs, stackTrace: stackTrace.withCurrentLoc())
|
||||
|
||||
expectEqual(expected.isLT(), lhsSub < rhsSub, stackTrace: stackTrace)
|
||||
expectEqual(expected.isLE(), lhsSub <= rhsSub, stackTrace: stackTrace)
|
||||
expectEqual(expected.isGE(), lhsSub >= rhsSub, stackTrace: stackTrace)
|
||||
expectEqual(expected.isGT(), lhsSub > rhsSub, stackTrace: stackTrace)
|
||||
checkComparable(
|
||||
expected, lhsSub, rhsSub, stackTrace: stackTrace.withCurrentLoc())
|
||||
}
|
||||
}
|
||||
|
||||
#if _runtime(_ObjC)
|
||||
// NSString / NSString
|
||||
@@ -471,5 +493,15 @@ StringTests.test("Regression/corelibs-foundation") {
|
||||
expectEqual(substring(of: s5, with: NSFakeRange(1,6)), "\ncats<EFBFBD>")
|
||||
}
|
||||
|
||||
StringTests.test("Regression/radar-87371813") {
|
||||
let s1 = "what♕/".dropFirst(5)
|
||||
let s2 = "/"[...]
|
||||
let s3 = "/⚅".dropLast()
|
||||
expectEqual(s1, s2)
|
||||
expectEqual(s1, s3)
|
||||
expectEqual(s1, s3)
|
||||
expectEqual(s1.hashValue, s2.hashValue)
|
||||
expectEqual(s2.hashValue, s3.hashValue)
|
||||
}
|
||||
|
||||
runAllTests()
|
||||
|
||||
Reference in New Issue
Block a user