@@ -14,7 +14,7 @@ import SwiftPrivate
1414//
1515// These scalars should be "base characters" with regards to their position in
1616// a grapheme cluster.
17- let baseScalars = [
17+ let baseScalars : [ UnicodeScalar ] = [
1818 // U+0065 LATIN SMALL LETTER E
1919 " \u{0065} " ,
2020
@@ -54,7 +54,7 @@ let baseScalars = [
5454
5555// Single Unicode scalars that are "continuing characters" with regards to
5656// their position in a grapheme cluster.
57- let continuingScalars = [
57+ let continuingScalars : [ UnicodeScalar ] = [
5858 // U+0300 COMBINING GRAVE ACCENT
5959 " \u{0300} " ,
6060
@@ -94,9 +94,9 @@ let testCharacters = [
9494
9595func randomGraphemeCluster( _ minSize: Int , _ maxSize: Int ) -> String {
9696 let n = pickRandom ( ( minSize + 1 ) ..< maxSize)
97- var result = pickRandom ( baseScalars)
97+ var result = String ( pickRandom ( baseScalars) )
9898 for _ in 0 ..< n {
99- result += pickRandom ( continuingScalars)
99+ result += String ( pickRandom ( continuingScalars) )
100100 }
101101 return result
102102}
@@ -150,8 +150,8 @@ CharacterTests.test("sizeof") {
150150
151151CharacterTests . test ( " Hashable " ) {
152152 for characters in [
153- baseScalars,
154- continuingScalars,
153+ baseScalars. map { String ( $0 ) } ,
154+ continuingScalars. map { String ( $0 ) } ,
155155 testCharacters
156156 ] {
157157 for i in characters. indices {
@@ -197,8 +197,8 @@ func checkRepresentation(_ s: String) {
197197CharacterTests . test ( " RoundTripping " ) {
198198 // Single Unicode Scalar Value tests
199199 for s in baseScalars {
200- checkRepresentation ( s )
201- checkRoundTripThroughCharacter ( s )
200+ checkRepresentation ( String ( s ) )
201+ checkRoundTripThroughCharacter ( String ( s ) )
202202 }
203203
204204 // Edge case tests
@@ -274,7 +274,7 @@ UnicodeScalarTests.test("UInt8(ascii: UnicodeScalar)/non-ASCII should trap")
274274}
275275
276276UnicodeScalarTests . test ( " UInt32(_: UnicodeScalar),UInt64(_: UnicodeScalar) " ) {
277- for us in baseScalars. map ( { $0 . unicodeScalars . first! } ) {
277+ for us in baseScalars {
278278 expectEqual ( us. value, UInt32 ( us) )
279279 expectEqual ( UInt64 ( us. value) , UInt64 ( us) )
280280 }
@@ -304,5 +304,12 @@ UnicodeScalarTests.test("Comparable") {
304304 expectTrue ( " B " >= CharA)
305305}
306306
307+ UnicodeScalarTests . test ( " LosslessStringConvertible " ) {
308+ // FIXME: these tests are insufficient.
309+
310+ checkLosslessStringConvertible ( ( 0xE000 ... 0xF000 ) . map { UnicodeScalar ( Int ( $0) ) ! } )
311+ checkLosslessStringConvertible ( ( 0 ... 127 ) . map { UnicodeScalar ( Int ( $0) ) ! } )
312+ }
313+
307314runAllTests ( )
308315
0 commit comments