@@ -28,7 +28,7 @@ func dumpIndices(_ string: String) {
28
28
let char = string [ i]
29
29
print ( " \( i) -> \( String ( reflecting: char) ) " )
30
30
}
31
- print ( " Unicode Scalars:" )
31
+ print ( " Scalars: " )
32
32
string. unicodeScalars. indices. forEach { i in
33
33
let scalar = string. unicodeScalars [ i]
34
34
let value = String ( scalar. value, radix: 16 , uppercase: true )
@@ -978,19 +978,20 @@ suite.test("Substring.replaceSubrange index validation")
978
978
let sm = scalarMap [ m] !. index
979
979
let sn = scalarMap [ n] !. index
980
980
981
- // Check Substring.replaceSubrange(_:with:)
982
- do {
983
- let replacement = " x "
981
+ let replacement = " x "
984
982
985
- var expected = " " . unicodeScalars
986
- expected += string. unicodeScalars [ si ..< sm]
987
- expected += replacement. unicodeScalars
988
- expected += string. unicodeScalars [ sn ..< sj]
983
+ var _expected = " " . unicodeScalars
984
+ _expected += string. unicodeScalars [ si ..< sm]
985
+ _expected += replacement. unicodeScalars
986
+ _expected += string. unicodeScalars [ sn ..< sj]
987
+ let expected = String ( _expected) [ ... ]
989
988
989
+ // Check Substring.replaceSubrange(_:with:)
990
+ do {
990
991
var actual = substring
991
- actual. replaceSubrange ( m ..< n, with: replacement)
992
+ actual. replaceSubrange ( m ..< n, with: Array ( replacement) )
992
993
993
- expectEqual ( actual, Substring ( expected [ ... ] ) ,
994
+ expectEqual ( actual, expected,
994
995
"""
995
996
string: \( string. debugDescription)
996
997
i: \( i)
@@ -1002,27 +1003,17 @@ suite.test("Substring.replaceSubrange index validation")
1002
1003
1003
1004
// Check String.unicodeScalars.replaceSubrange(_:with:)
1004
1005
do {
1005
- let replacement = " x " . unicodeScalars
1006
-
1007
- var expected = " " . unicodeScalars
1008
- expected += string. unicodeScalars [ si ..< sm]
1009
- expected += replacement
1010
- expected += string. unicodeScalars [ sn ..< sj]
1011
-
1012
1006
var actual = substring
1013
- actual. unicodeScalars. replaceSubrange ( m ..< n, with: replacement)
1007
+ actual. unicodeScalars. replaceSubrange (
1008
+ m ..< n, with: Array ( replacement. unicodeScalars) )
1014
1009
1015
- expectEqual ( actual, Substring ( expected [ ... ] ) ,
1010
+ expectEqual ( actual, expected,
1016
1011
"""
1017
1012
string: \( string. debugDescription)
1018
1013
i: \( i)
1019
1014
j: \( j)
1020
1015
m: \( m)
1021
1016
n: \( n)
1022
- substring.startIndex: \( substring. startIndex)
1023
- substring.endIndex: \( substring. endIndex)
1024
- actual.startIndex: \( actual. startIndex)
1025
- actual.endIndex: \( actual. endIndex)
1026
1017
""" )
1027
1018
}
1028
1019
}
0 commit comments