mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Removed some warnings (#12753)
This commit is contained in:
@@ -88,10 +88,11 @@ NSStringAPIs.test("NSStringEncoding") {
|
||||
enc = .utf32BigEndian
|
||||
enc = .ascii
|
||||
enc = .utf8
|
||||
expectEqual(.utf8, enc)
|
||||
}
|
||||
|
||||
NSStringAPIs.test("localizedStringWithFormat(_:...)") {
|
||||
var world: NSString = "world"
|
||||
let world: NSString = "world"
|
||||
expectEqual("Hello, world!%42", String.localizedStringWithFormat(
|
||||
"Hello, %@!%%%ld", world, 42))
|
||||
|
||||
@@ -118,7 +119,7 @@ NSStringAPIs.test("init(contentsOfFile:encoding:error:)") {
|
||||
}
|
||||
|
||||
do {
|
||||
let content = try String(
|
||||
let _ = try String(
|
||||
contentsOfFile: nonExistentPath, encoding: .ascii)
|
||||
expectUnreachable()
|
||||
} catch {
|
||||
@@ -140,7 +141,7 @@ NSStringAPIs.test("init(contentsOfFile:usedEncoding:error:)") {
|
||||
expectUnreachableCatch(error)
|
||||
}
|
||||
|
||||
var usedEncoding: String.Encoding = String.Encoding(rawValue: 0)
|
||||
let usedEncoding: String.Encoding = String.Encoding(rawValue: 0)
|
||||
do {
|
||||
_ = try String(contentsOfFile: nonExistentPath)
|
||||
expectUnreachable()
|
||||
@@ -204,8 +205,8 @@ NSStringAPIs.test("init(cString_:encoding:)") {
|
||||
}
|
||||
|
||||
NSStringAPIs.test("init(utf8String:)") {
|
||||
var s = "foo あいう"
|
||||
var up = UnsafeMutablePointer<UInt8>.allocate(capacity: 100)
|
||||
let s = "foo あいう"
|
||||
let up = UnsafeMutablePointer<UInt8>.allocate(capacity: 100)
|
||||
var i = 0
|
||||
for b in s.utf8 {
|
||||
up[i] = b
|
||||
@@ -374,13 +375,13 @@ NSStringAPIs.test("compare(_:options:range:locale:)") {
|
||||
NSStringAPIs.test("completePath(into:caseSensitive:matchesInto:filterTypes)") {
|
||||
let (existingPath, nonExistentPath) = createNSStringTemporaryFile()
|
||||
do {
|
||||
var count = nonExistentPath.completePath(caseSensitive: false)
|
||||
let count = nonExistentPath.completePath(caseSensitive: false)
|
||||
expectEqual(0, count)
|
||||
}
|
||||
|
||||
do {
|
||||
var outputName = "None Found"
|
||||
var count = nonExistentPath.completePath(
|
||||
let count = nonExistentPath.completePath(
|
||||
into: &outputName, caseSensitive: false)
|
||||
|
||||
expectEqual(0, count)
|
||||
@@ -390,7 +391,7 @@ NSStringAPIs.test("completePath(into:caseSensitive:matchesInto:filterTypes)") {
|
||||
do {
|
||||
var outputName = "None Found"
|
||||
var outputArray: [String] = ["foo", "bar"]
|
||||
var count = nonExistentPath.completePath(
|
||||
let count = nonExistentPath.completePath(
|
||||
into: &outputName, caseSensitive: false, matchesInto: &outputArray)
|
||||
|
||||
expectEqual(0, count)
|
||||
@@ -399,13 +400,13 @@ NSStringAPIs.test("completePath(into:caseSensitive:matchesInto:filterTypes)") {
|
||||
}
|
||||
|
||||
do {
|
||||
var count = existingPath.completePath(caseSensitive: false)
|
||||
let count = existingPath.completePath(caseSensitive: false)
|
||||
expectEqual(1, count)
|
||||
}
|
||||
|
||||
do {
|
||||
var outputName = "None Found"
|
||||
var count = existingPath.completePath(
|
||||
let count = existingPath.completePath(
|
||||
into: &outputName, caseSensitive: false)
|
||||
|
||||
expectEqual(1, count)
|
||||
@@ -415,7 +416,7 @@ NSStringAPIs.test("completePath(into:caseSensitive:matchesInto:filterTypes)") {
|
||||
do {
|
||||
var outputName = "None Found"
|
||||
var outputArray: [String] = ["foo", "bar"]
|
||||
var count = existingPath.completePath(
|
||||
let count = existingPath.completePath(
|
||||
into: &outputName, caseSensitive: false, matchesInto: &outputArray)
|
||||
|
||||
expectEqual(1, count)
|
||||
@@ -425,7 +426,7 @@ NSStringAPIs.test("completePath(into:caseSensitive:matchesInto:filterTypes)") {
|
||||
|
||||
do {
|
||||
var outputName = "None Found"
|
||||
var count = existingPath.completePath(
|
||||
let count = existingPath.completePath(
|
||||
into: &outputName, caseSensitive: false, filterTypes: ["txt"])
|
||||
|
||||
expectEqual(1, count)
|
||||
@@ -472,7 +473,7 @@ NSStringAPIs.test("cString(usingEncoding:)") {
|
||||
expectNil("абв".cString(using: .ascii))
|
||||
|
||||
let expectedBytes: [UInt8] = [ 0xd0, 0xb0, 0xd0, 0xb1, 0xd0, 0xb2, 0 ]
|
||||
var expectedStr: [CChar] = expectedBytes.map { CChar(bitPattern: $0) }
|
||||
let expectedStr: [CChar] = expectedBytes.map { CChar(bitPattern: $0) }
|
||||
expectEqual(expectedStr,
|
||||
"абв".cString(using: .utf8)!)
|
||||
}
|
||||
@@ -496,8 +497,8 @@ NSStringAPIs.test("init(data:encoding:)") {
|
||||
expectNil(String(data: data, encoding: .nonLossyASCII))
|
||||
|
||||
expectEqualSequence(
|
||||
"あいう".characters,
|
||||
String(data: data, encoding: .utf8)!.characters)
|
||||
"あいう",
|
||||
String(data: data, encoding: .utf8)!)
|
||||
}
|
||||
|
||||
NSStringAPIs.test("decomposedStringWithCanonicalMapping") {
|
||||
@@ -606,7 +607,7 @@ NSStringAPIs.test("getBytes(_:maxLength:usedLength:encoding:options:range:remain
|
||||
var buffer = [UInt8](repeating: 0xff, count: bufferLength)
|
||||
var usedLength = 0
|
||||
var remainingRange = startIndex..<endIndex
|
||||
var result = s.getBytes(&buffer, maxLength: 11, usedLength: &usedLength,
|
||||
let result = s.getBytes(&buffer, maxLength: 11, usedLength: &usedLength,
|
||||
encoding: .utf8,
|
||||
options: [],
|
||||
range: startIndex..<endIndex, remaining: &remainingRange)
|
||||
@@ -627,7 +628,7 @@ NSStringAPIs.test("getBytes(_:maxLength:usedLength:encoding:options:range:remain
|
||||
var buffer = [UInt8](repeating: 0xff, count: bufferLength)
|
||||
var usedLength = 0
|
||||
var remainingRange = startIndex..<endIndex
|
||||
var result = s.getBytes(&buffer, maxLength: 11, usedLength: &usedLength,
|
||||
let result = s.getBytes(&buffer, maxLength: 11, usedLength: &usedLength,
|
||||
encoding: .utf8,
|
||||
options: [],
|
||||
range: startIndex..<endIndex, remaining: &remainingRange)
|
||||
@@ -647,7 +648,7 @@ NSStringAPIs.test("getBytes(_:maxLength:usedLength:encoding:options:range:remain
|
||||
var buffer = [UInt8](repeating: 0xff, count: bufferLength)
|
||||
var usedLength = 0
|
||||
var remainingRange = startIndex..<endIndex
|
||||
var result = s.getBytes(&buffer, maxLength: bufferLength,
|
||||
let result = s.getBytes(&buffer, maxLength: bufferLength,
|
||||
usedLength: &usedLength, encoding: .utf8,
|
||||
options: [],
|
||||
range: startIndex..<endIndex, remaining: &remainingRange)
|
||||
@@ -667,7 +668,7 @@ NSStringAPIs.test("getBytes(_:maxLength:usedLength:encoding:options:range:remain
|
||||
var buffer = [UInt8](repeating: 0xff, count: bufferLength)
|
||||
var usedLength = 0
|
||||
var remainingRange = startIndex..<endIndex
|
||||
var result = s.getBytes(&buffer, maxLength: bufferLength,
|
||||
let result = s.getBytes(&buffer, maxLength: bufferLength,
|
||||
usedLength: &usedLength, encoding: .ascii,
|
||||
options: [],
|
||||
range: startIndex..<endIndex, remaining: &remainingRange)
|
||||
@@ -680,7 +681,7 @@ NSStringAPIs.test("getBytes(_:maxLength:usedLength:encoding:options:range:remain
|
||||
}
|
||||
|
||||
NSStringAPIs.test("getCString(_:maxLength:encoding:)") {
|
||||
var s = "abc あかさた"
|
||||
let s = "abc あかさた"
|
||||
do {
|
||||
// The largest buffer that cannot accommodate the string plus null terminator.
|
||||
let bufferLength = 16
|
||||
@@ -758,8 +759,8 @@ NSStringAPIs.test("getParagraphStart(_:end:contentsEnd:forRange:)") {
|
||||
}
|
||||
|
||||
NSStringAPIs.test("hash") {
|
||||
var s: String = "abc"
|
||||
var nsstr: NSString = "abc"
|
||||
let s: String = "abc"
|
||||
let nsstr: NSString = "abc"
|
||||
expectEqual(nsstr.hash, s.hash)
|
||||
}
|
||||
|
||||
@@ -839,7 +840,7 @@ NSStringAPIs.test("init(format:arguments:)") {
|
||||
}
|
||||
|
||||
NSStringAPIs.test("init(format:locale:_:...)") {
|
||||
var world: NSString = "world"
|
||||
let world: NSString = "world"
|
||||
expectEqual("Hello, world!%42", String(format: "Hello, %@!%%%ld",
|
||||
locale: nil, world, 42))
|
||||
}
|
||||
@@ -875,7 +876,7 @@ NSStringAPIs.test("linguisticTagsIn(_:scheme:options:orthography:tokenRanges:)")
|
||||
let startIndex = s.index(s.startIndex, offsetBy: 5)
|
||||
let endIndex = s.index(s.startIndex, offsetBy: 17)
|
||||
var tokenRanges: [Range<String.Index>] = []
|
||||
var tags = s.linguisticTags(in: startIndex..<endIndex,
|
||||
let tags = s.linguisticTags(in: startIndex..<endIndex,
|
||||
scheme: NSLinguisticTagSchemeTokenType,
|
||||
options: [],
|
||||
orthography: nil, tokenRanges: &tokenRanges)
|
||||
|
||||
Reference in New Issue
Block a user