Skip to content

Commit c9fe38d

Browse files
committed
TestFoundation: use bridging for CFStringGetLength
Rather than use CoreFoundation interfaces, use bridging more aggressively to call the CoreFoundation methods. This reduces the dependency on CoreFoundation for the test suite.
1 parent 2e4aa1c commit c9fe38d

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
@@ -606,7 +606,7 @@ class TestNSString: LoopbackServerTest {
606606
buf.reserveCapacity(reservedLength)
607607
var usedLen : CFIndex = 0
608608
let _ = buf.withUnsafeMutableBufferPointer { p in
609-
CFStringGetBytes(cfString, CFRangeMake(0, CFStringGetLength(cfString)), CFStringEncoding(kCFStringEncodingUTF16), 0, false, p.baseAddress, reservedLength, &usedLen)
609+
CFStringGetBytes(cfString, CFRangeMake(0, unsafeBitCast(cfString, to: NSString.self).length), CFStringEncoding(kCFStringEncodingUTF16), 0, false, p.baseAddress, reservedLength, &usedLen)
610610
}
611611

612612
// Make a new string out of it
@@ -1299,11 +1299,11 @@ class TestNSString: LoopbackServerTest {
12991299
}
13001300

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

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

13091309
func test_createCopy() {

0 commit comments

Comments
 (0)