@@ -601,11 +601,11 @@ StringTests.test("appendToSubstringBug")
601
601
if s0. unusedCapacity == 0 { s0 += " y " }
602
602
let cap = s0. unusedCapacity
603
603
expectNotEqual ( 0 , cap)
604
-
604
+
605
605
// This sorta checks for the original bug
606
606
expectEqual (
607
607
cap, String ( s0 [ s0. index ( _nth: 1 ) ..< s0. endIndex] ) . unusedCapacity)
608
-
608
+
609
609
return ( s0, cap)
610
610
}
611
611
@@ -615,7 +615,7 @@ StringTests.test("appendToSubstringBug")
615
615
return ( String ( s0 [ s0. index ( _nth: 5 ) ..< s0. endIndex] ) , unused)
616
616
} ( )
617
617
let originalID = s. bufferID
618
- // Appending to a String always results in storage that
618
+ // Appending to a String always results in storage that
619
619
// starts at the beginning of its native buffer
620
620
s += " z "
621
621
expectNotEqual ( originalID, s. bufferID)
@@ -879,15 +879,15 @@ StringTests.test("stringGutsExtensibility")
879
879
for k in 0 ..< 3 {
880
880
for count in 1 ..< 16 {
881
881
for boundary in 0 ..< count {
882
-
882
+
883
883
var x = (
884
884
k == 0 ? asciiString ( " b " )
885
885
: k == 1 ? ( " b " as NSString as String )
886
886
: ( " b " as NSMutableString as String )
887
887
)
888
888
889
889
if k == 0 { expectTrue ( x. _guts. isFastUTF8) }
890
-
890
+
891
891
for i in 0 ..< count {
892
892
x. append ( String (
893
893
decoding: repeatElement ( i < boundary ? ascii : nonAscii, count: 3 ) ,
@@ -896,7 +896,7 @@ StringTests.test("stringGutsExtensibility")
896
896
// Make sure we can append pure ASCII to wide storage
897
897
x. append ( String (
898
898
decoding: repeatElement ( ascii, count: 2 ) , as: UTF16 . self) )
899
-
899
+
900
900
expectEqualSequence (
901
901
[ UTF16 . CodeUnit ( UnicodeScalar ( " b " ) . value) ]
902
902
+ Array( repeatElement ( ascii, count: 3 * boundary) )
@@ -950,17 +950,17 @@ StringTests.test("stringGutsReserve")
950
950
fatalError ( " case unhandled! " )
951
951
}
952
952
expectEqual ( isSwiftNative ( base) , startedNative)
953
-
953
+
954
954
let originalBuffer = base. bufferID
955
955
let isUnique = base. _guts. isUniqueNative
956
956
let startedUnique =
957
957
startedNative &&
958
958
base. _classify ( ) . _objectIdentifier != nil &&
959
959
isUnique
960
-
960
+
961
961
base. reserveCapacity ( 16 )
962
962
// Now it's unique
963
-
963
+
964
964
// If it was already native and unique, no reallocation
965
965
if startedUnique && startedNative {
966
966
expectEqual ( originalBuffer, base. bufferID)
@@ -1301,22 +1301,22 @@ StringTests.test("unicodeViews") {
1301
1301
// FIXME: note changed String(describing:) results
1302
1302
expectEqual(
1303
1303
"\u{FFFD}",
1304
- String(describing:
1304
+ String(describing:
1305
1305
winter.utf8[
1306
1306
winter.utf8.startIndex
1307
1307
..<
1308
1308
winter.utf8.index(after: winter.utf8.index(after: winter.utf8.startIndex))
1309
1309
]))
1310
1310
*/
1311
-
1311
+
1312
1312
expectEqual (
1313
1313
" \u{1F3C2} " , String (
1314
1314
winter. utf8 [ winter. utf8. startIndex..< winter. utf8. index ( _nth: 4 ) ] ) )
1315
1315
1316
1316
expectEqual (
1317
1317
" \u{1F3C2} " , String (
1318
1318
winter. utf16 [ winter. utf16. startIndex..< winter. utf16. index ( _nth: 2 ) ] ) )
1319
-
1319
+
1320
1320
expectEqual (
1321
1321
" \u{1F3C2} " , String (
1322
1322
winter. unicodeScalars [
@@ -1357,7 +1357,7 @@ StringTests.test("indexConversion")
1357
1357
let s = " go further into the larder to barter. "
1358
1358
1359
1359
var matches : [ String ] = [ ]
1360
-
1360
+
1361
1361
re. enumerateMatches (
1362
1362
in: s, options: NSRegularExpression . MatchingOptions ( ) , range: NSRange ( 0 ..< s. utf16. count)
1363
1363
) {
@@ -1811,18 +1811,18 @@ public let testSuffix = "z"
1811
1811
StringTests . test ( " COW.Smoke " ) {
1812
1812
var s1 = " COW Smoke Cypseloides " + testSuffix
1813
1813
let identity1 = s1. _rawIdentifier ( )
1814
-
1814
+
1815
1815
var s2 = s1
1816
1816
expectEqual ( identity1, s2. _rawIdentifier ( ) )
1817
-
1817
+
1818
1818
s2. append ( " cryptus " )
1819
1819
expectTrue ( identity1 != s2. _rawIdentifier ( ) )
1820
-
1820
+
1821
1821
s1. remove ( at: s1. startIndex)
1822
1822
expectEqual ( identity1, s1. _rawIdentifier ( ) )
1823
-
1823
+
1824
1824
_fixLifetime ( s1)
1825
- _fixLifetime ( s2)
1825
+ _fixLifetime ( s2)
1826
1826
}
1827
1827
1828
1828
struct COWStringTest {
@@ -1840,17 +1840,17 @@ for test in testCases {
1840
1840
StringTests . test ( " COW. \( test. name) .IndexesDontAffectUniquenessCheck " ) {
1841
1841
let s = test. test + testSuffix
1842
1842
let identity1 = s. _rawIdentifier ( )
1843
-
1843
+
1844
1844
let startIndex = s. startIndex
1845
1845
let endIndex = s. endIndex
1846
1846
expectNotEqual ( startIndex, endIndex)
1847
1847
expectLT ( startIndex, endIndex)
1848
1848
expectLE ( startIndex, endIndex)
1849
1849
expectGT ( endIndex, startIndex)
1850
1850
expectGE ( endIndex, startIndex)
1851
-
1851
+
1852
1852
expectEqual ( identity1, s. _rawIdentifier ( ) )
1853
-
1853
+
1854
1854
// Keep indexes alive during the calls above
1855
1855
_fixLifetime ( startIndex)
1856
1856
_fixLifetime ( endIndex)
@@ -1972,7 +1972,7 @@ for test in testCases {
1972
1972
1973
1973
expectGT ( s. count, 0 )
1974
1974
expectEqual ( identity1, s. _rawIdentifier ( ) )
1975
- }
1975
+ }
1976
1976
}
1977
1977
1978
1978
for test in testCases {
@@ -2027,16 +2027,16 @@ enum _Ordering: Int, Equatable {
2027
2027
}
2028
2028
}
2029
2029
2030
- struct ComparisonTestCase {
2030
+ struct ComparisonTestCase {
2031
2031
var strings : [ String ]
2032
2032
// var test: (String, String) -> Void
2033
2033
var comparison : _Ordering
2034
-
2034
+
2035
2035
init ( _ strings: [ String ] , _ comparison: _Ordering ) {
2036
2036
self . strings = strings
2037
2037
self . comparison = comparison
2038
2038
}
2039
-
2039
+
2040
2040
func test( ) {
2041
2041
for pair in zip ( strings, strings [ 1 ... ] ) {
2042
2042
switch comparison {
@@ -2063,7 +2063,7 @@ struct ComparisonTestCase {
2063
2063
}
2064
2064
}
2065
2065
}
2066
-
2066
+
2067
2067
func testOpaqueStrings( ) {
2068
2068
#if _runtime(_ObjC)
2069
2069
let opaqueStrings = strings. map { NSSlowString ( string: $0) as String }
@@ -2080,16 +2080,16 @@ struct ComparisonTestCase {
2080
2080
expectEqualSequence ( strings, opaqueStrings)
2081
2081
#endif
2082
2082
}
2083
-
2083
+
2084
2084
func testOpaqueSubstrings( ) {
2085
2085
#if _runtime(_ObjC)
2086
2086
for pair in zip ( strings, strings [ 1 ... ] ) {
2087
2087
let string1 = pair. 0 . dropLast ( )
2088
2088
let string2 = pair. 1
2089
2089
let opaqueString = ( NSSlowString ( string: pair. 0 ) as String ) . dropLast ( )
2090
-
2090
+
2091
2091
guard string1. count > 0 else { return }
2092
-
2092
+
2093
2093
expectEqual ( string1, opaqueString)
2094
2094
expectEqual ( string1 < string2, opaqueString < string2)
2095
2095
expectEqual ( string1 > string2, opaqueString > string2)
@@ -2109,7 +2109,7 @@ let comparisonTestCases = [
2109
2109
2110
2110
ComparisonTestCase ( [ " á " , " \u{0061} \u{0301} " ] , . equal) ,
2111
2111
ComparisonTestCase ( [ " à " , " \u{0061} \u{0301} " , " â " , " \u{e3} " , " a \u{0308} " ] , . less) ,
2112
-
2112
+
2113
2113
// Exploding scalars AND exploding segments
2114
2114
ComparisonTestCase ( [ " \u{fa2} " , " \u{fa1} \u{fb7} " ] , . equal) ,
2115
2115
ComparisonTestCase ( [
@@ -2142,15 +2142,15 @@ let comparisonTestCases = [
2142
2142
" 🧀 " // D83E DDC0 -- aka a really big scalar
2143
2143
] , . less) ,
2144
2144
2145
-
2145
+
2146
2146
ComparisonTestCase ( [ " f̛̗̘̙̜̹̺̻̼͇͈͉͍͎̽̾̿̀́͂̓̈́͆͊͋͌̚ͅ͏͓͔͕͖͙͚͐͑͒͗͛ͣͤͥͦ͘͜͟͢͝͞͠͡ " , " ơ̗̘̙̜̹̺̻̼͇͈͉͍͎̽̾̿̀́͂̓̈́͆͊͋͌̚ͅ͏͓͔͕͖͙͚͐͑͒͗͛ͥͦͧͨͩͪͫͬͭͮ͘ " ] , . less) ,
2147
2147
ComparisonTestCase ( [ " \u{f90b} " , " \u{5587} " ] , . equal) ,
2148
-
2148
+
2149
2149
ComparisonTestCase ( [ " a \u{1D160} a " , " a \u{1D158} \u{1D1C7} " ] , . less) ,
2150
2150
2151
2151
ComparisonTestCase ( [ " a \u{305} \u{315} " , " a \u{315} \u{305} " ] , . equal) ,
2152
2152
ComparisonTestCase ( [ " a \u{315} bz " , " a \u{315} \u{305} az " ] , . greater) ,
2153
-
2153
+
2154
2154
ComparisonTestCase ( [ " \u{212b} " , " \u{00c5} " ] , . equal) ,
2155
2155
ComparisonTestCase ( [
2156
2156
" A " ,
@@ -2180,7 +2180,7 @@ let comparisonTestCases = [
2180
2180
" \u{FFEE} " , // half width CJK dot
2181
2181
" 🧀 " , // D83E DDC0 -- aka a really big scalar
2182
2182
] , . less) ,
2183
-
2183
+
2184
2184
ComparisonTestCase ( [ " ư̴̵̶̷̸̗̘̙̜̹̺̻̼͇͈͉͍͎̽̾̿̀́͂̓̈́͆͊͋͌̚ͅ͏͓͔͕͖͙͚͐͑͒͗͛ͣͤͥͦͧͨͩͪͫͬͭͮ͘͜͟͢͝͞͠͡ " , " ì̡̢̧̨̝̞̟̠̣̤̥̦̩̪̫̬̭̮̯̰̹̺̻̼͇͈͉͍͎́̂̃̄̉̊̋̌̍̎̏̐̑̒̓̽̾̿̀́͂̓̈́͆͊͋͌ͅ͏͓͔͕͖͙͐͑͒͗ͬͭͮ͘ " ] , . greater) ,
2185
2185
ComparisonTestCase ( [ " ư̴̵̶̷̸̗̘̙̜̹̺̻̼͇͈͉͍͎̽̾̿̀́͂̓̈́͆͊͋͌̚ͅ͏͓͔͕͖͙͚͐͑͒͗͛ͣͤͥͦͧͨͩͪͫͬͭͮ͘͜͟͢͝͞͠͡ " , " aì̡̢̧̨̝̞̟̠̣̤̥̦̩̪̫̬̭̮̯̰̹̺̻̼͇͈͉͍͎́̂̃̄̉̊̋̌̍̎̏̐̑̒̓̽̾̿̀́͂̓̈́͆͊͋͌ͅ͏͓͔͕͖͙͐͑͒͗ͬͭͮ͘ " ] , . greater) ,
2186
2186
ComparisonTestCase ( [ " ì̡̢̧̨̝̞̟̠̣̤̥̦̩̪̫̬̭̮̯̰̹̺̻̼͇͈͉͍͎́̂̃̄̉̊̋̌̍̎̏̐̑̒̓̽̾̿̀́͂̓̈́͆͊͋͌ͅ͏͓͔͕͖͙͐͑͒͗ͬͭͮ͘ " , " ì̡̢̧̨̝̞̟̠̣̤̥̦̩̪̫̬̭̮̯̰̹̺̻̼͇͈͉͍͎́̂̃̄̉̊̋̌̍̎̏̐̑̒̓̽̾̿̀́͂̓̈́͆͊͋͌ͅ͏͓͔͕͖͙͐͑͒͗ͬͭͮ͘ " ] , . equal)
@@ -2208,7 +2208,7 @@ StringTests.test("Comparison.Substrings") {
2208
2208
let str = " abcdefg "
2209
2209
let expectedStr = " bcdef "
2210
2210
let substring = str. dropFirst ( ) . dropLast ( )
2211
-
2211
+
2212
2212
expectEqual ( expectedStr, substring)
2213
2213
}
2214
2214
@@ -2219,15 +2219,15 @@ StringTests.test("Comparison.Substrings/Opaque")
2219
2219
let str = NSSlowString ( string: " abcdefg " ) as String
2220
2220
let expectedStr = NSSlowString ( string: " bcdef " ) as String
2221
2221
let substring = str. dropFirst ( ) . dropLast ( )
2222
-
2222
+
2223
2223
expectEqual ( expectedStr, substring)
2224
2224
#endif
2225
2225
}
2226
2226
2227
2227
StringTests . test ( " NormalizationBufferCrashRegressionTest " ) {
2228
2228
let str = " \u{0336} \u{0344} \u{0357} \u{0343} \u{0314} \u{0351} \u{0340} \u{0300} \u{0340} \u{0360} \u{0314} \u{0357} \u{0315} \u{0301} \u{0344} a "
2229
2229
let set = Set ( [ str] )
2230
-
2230
+
2231
2231
expectTrue ( set. contains ( str) )
2232
2232
}
2233
2233
0 commit comments