Skip to content

Commit 0f18d1a

Browse files
authored
Merge pull request #2087 from compnerd/lengthy-change
TestFoundation: use bridging for CFStringGetLength
2 parents 966a936 + c9fe38d commit 0f18d1a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

TestFoundation/TestNSString.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ class TestNSString: LoopbackServerTest {
607607
buf.reserveCapacity(reservedLength)
608608
var usedLen : CFIndex = 0
609609
let _ = buf.withUnsafeMutableBufferPointer { p in
610-
CFStringGetBytes(cfString, CFRangeMake(0, CFStringGetLength(cfString)), CFStringEncoding(kCFStringEncodingUTF16), 0, false, p.baseAddress, reservedLength, &usedLen)
610+
CFStringGetBytes(cfString, CFRangeMake(0, unsafeBitCast(cfString, to: NSString.self).length), CFStringEncoding(kCFStringEncodingUTF16), 0, false, p.baseAddress, reservedLength, &usedLen)
611611
}
612612

613613
// Make a new string out of it
@@ -1300,11 +1300,11 @@ class TestNSString: LoopbackServerTest {
13001300
}
13011301

13021302
func test_substringFromCFString() {
1303-
let cfString = kCFStringTransformStripCombiningMarks!
1304-
let range = NSRange(location: 0, length: CFStringGetLength(cfString))
1305-
let substring = unsafeBitCast(cfString, to: NSString.self).substring(with: range)
1303+
let string = NSString.StringTransform.stripCombiningMarks.rawValue as NSString
1304+
let range = NSRange(location: 0, length: string.length)
1305+
let substring = string.substring(with: range)
13061306

1307-
XCTAssertEqual(CFStringGetLength(cfString), substring.utf16.count)
1307+
XCTAssertEqual(string.length, substring.utf16.count)
13081308
}
13091309

13101310
func test_createCopy() {

0 commit comments

Comments
 (0)