@@ -73,6 +73,7 @@ class TestNSString : XCTestCase {
73
73
( " test_stringByTrimmingCharactersInSet " , test_stringByTrimmingCharactersInSet) ,
74
74
( " test_initializeWithFormat " , test_initializeWithFormat) ,
75
75
( " test_initializeWithFormat2 " , test_initializeWithFormat2) ,
76
+ ( " test_initializeWithFormat3 " , test_initializeWithFormat3) ,
76
77
( " test_stringByDeletingLastPathComponent " , test_stringByDeletingLastPathComponent) ,
77
78
( " test_getCString_simple " , test_getCString_simple) ,
78
79
( " test_getCString_nonASCII_withASCIIAccessor " , test_getCString_nonASCII_withASCIIAccessor) ,
@@ -617,6 +618,35 @@ class TestNSString : XCTestCase {
617
618
XCTAssertEqual ( string, " 4B " )
618
619
}
619
620
621
+ func test_initializeWithFormat3( ) {
622
+ let argument : [ CVarArg ] = [ 1000 , 42.0 ]
623
+
624
+ withVaList ( argument) {
625
+ pointer in
626
+ let string = NSString ( format: " Default value is %d (%.1f) " , locale: nil , arguments: pointer)
627
+ XCTAssertEqual ( string, " Default value is 1000 (42.0) " )
628
+ }
629
+
630
+ withVaList ( argument) {
631
+ pointer in
632
+ let string = NSString ( format: " en_GB value is %d (%.1f) " , locale: NSLocale . init ( localeIdentifier: " en_GB " ) , arguments: pointer)
633
+ XCTAssertEqual ( string, " en_GB value is 1,000 (42.0) " )
634
+ }
635
+
636
+ withVaList ( argument) {
637
+ pointer in
638
+ let string = NSString ( format: " de_DE value is %d (%.1f) " , locale: NSLocale . init ( localeIdentifier: " de_DE " ) , arguments: pointer)
639
+ XCTAssertEqual ( string, " de_DE value is 1.000 (42,0) " )
640
+ }
641
+
642
+ withVaList ( argument) {
643
+ pointer in
644
+ let loc : NSDictionary = [ " NSDecimalSeparator " as NSString : " & " as NSString ]
645
+ let string = NSString ( format: " NSDictionary value is %d (%.1f) " , locale: loc, arguments: pointer)
646
+ XCTAssertEqual ( string, " NSDictionary value is 1000 (42&0) " )
647
+ }
648
+ }
649
+
620
650
func test_stringByDeletingLastPathComponent( ) {
621
651
do {
622
652
let path : NSString = " /tmp/scratch.tiff "
0 commit comments