mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Change unicodescalar to failable
We were using a precondition which crashes the program when invalid input is provided. We want to provide a way to gracefully check and handle invalid input or shutdown the program if necessary. SR-1930
This commit is contained in:
@@ -21,8 +21,8 @@ UTF8Decoder.test("Internal/_decodeOne") {
|
||||
expectOptionalEqual(scalar.value, codePoint, "data=\(asHex(data))")
|
||||
}
|
||||
|
||||
for i in 0..<0xd800 { ensureValid(UnicodeScalar(i)) }
|
||||
for i in 0xe000...0x10ffff { ensureValid(UnicodeScalar(i)) }
|
||||
for i in 0..<0xd800 { ensureValid(UnicodeScalar(i)!) }
|
||||
for i in 0xe000...0x10ffff { ensureValid(UnicodeScalar(i)!) }
|
||||
|
||||
// Check number of valid/invalid sequences of different lengths
|
||||
var validLengthCounts = [ 0, 0, 0, 0, 0 ]
|
||||
|
||||
Reference in New Issue
Block a user