File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -1644,3 +1644,24 @@ extension NSString : _StructTypeBridgeable {
16441644 return _StructType. _unconditionallyBridgeFromObjectiveC ( self )
16451645 }
16461646}
1647+
1648+ extension NSString : CVarArg {
1649+ @inlinable // c-abi
1650+ public var _cVarArgEncoding : [ Int ] {
1651+ return _encodeBitsAsWords ( unsafeBitCast ( self , to: AnyObject . self) )
1652+ }
1653+ }
1654+
1655+ #if !_runtime(_ObjC)
1656+ extension String : CVarArg , _CVarArgObject {
1657+ @inlinable // c-abi
1658+ public var _cVarArgObject : CVarArg {
1659+ return NSString ( string: self )
1660+ }
1661+
1662+ @inlinable // c-abi
1663+ public var _cVarArgEncoding : [ Int ] {
1664+ fatalError ( " _cVarArgEncoding must be called on NSString instead " )
1665+ }
1666+ }
1667+ #endif
Original file line number Diff line number Diff line change @@ -813,6 +813,15 @@ class TestNSString: LoopbackServerTest {
813813 }
814814 }
815815
816+ func test_initializeWithFormat4( ) {
817+ let argument : [ CVarArg ] = [ " One " , " Two " , " Three " ]
818+ withVaList ( argument) {
819+ pointer in
820+ let string = NSString ( format: " Testing %@ %@ %@ " , arguments: pointer)
821+ XCTAssertEqual ( string, " Testing One Two Three " )
822+ }
823+ }
824+
816825 func test_appendingPathComponent( ) {
817826 do {
818827 let path : NSString = " /tmp "
@@ -1677,6 +1686,7 @@ class TestNSString: LoopbackServerTest {
16771686 ( " test_initializeWithFormat " , test_initializeWithFormat) ,
16781687 ( " test_initializeWithFormat2 " , test_initializeWithFormat2) ,
16791688 ( " test_initializeWithFormat3 " , test_initializeWithFormat3) ,
1689+ ( " test_initializeWithFormat4 " , test_initializeWithFormat4) ,
16801690 ( " test_appendingPathComponent " , test_appendingPathComponent) ,
16811691 ( " test_deletingLastPathComponent " , test_deletingLastPathComponent) ,
16821692 ( " test_getCString_simple " , test_getCString_simple) ,
You can’t perform that action at this time.
0 commit comments