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 {
1644
1644
return _StructType. _unconditionallyBridgeFromObjectiveC ( self )
1645
1645
}
1646
1646
}
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 {
813
813
}
814
814
}
815
815
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
+
816
825
func test_appendingPathComponent( ) {
817
826
do {
818
827
let path : NSString = " /tmp "
@@ -1677,6 +1686,7 @@ class TestNSString: LoopbackServerTest {
1677
1686
( " test_initializeWithFormat " , test_initializeWithFormat) ,
1678
1687
( " test_initializeWithFormat2 " , test_initializeWithFormat2) ,
1679
1688
( " test_initializeWithFormat3 " , test_initializeWithFormat3) ,
1689
+ ( " test_initializeWithFormat4 " , test_initializeWithFormat4) ,
1680
1690
( " test_appendingPathComponent " , test_appendingPathComponent) ,
1681
1691
( " test_deletingLastPathComponent " , test_deletingLastPathComponent) ,
1682
1692
( " test_getCString_simple " , test_getCString_simple) ,
You can’t perform that action at this time.
0 commit comments