@@ -73,6 +73,7 @@ class TestNSString : XCTestCase {
7373 ( " test_stringByTrimmingCharactersInSet " , test_stringByTrimmingCharactersInSet) ,
7474 ( " test_initializeWithFormat " , test_initializeWithFormat) ,
7575 ( " test_initializeWithFormat2 " , test_initializeWithFormat2) ,
76+ ( " test_initializeWithFormat3 " , test_initializeWithFormat3) ,
7677 ( " test_stringByDeletingLastPathComponent " , test_stringByDeletingLastPathComponent) ,
7778 ( " test_getCString_simple " , test_getCString_simple) ,
7879 ( " test_getCString_nonASCII_withASCIIAccessor " , test_getCString_nonASCII_withASCIIAccessor) ,
@@ -617,6 +618,35 @@ class TestNSString : XCTestCase {
617618 XCTAssertEqual ( string, " 4B " )
618619 }
619620
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+
620650 func test_stringByDeletingLastPathComponent( ) {
621651 do {
622652 let path : NSString = " /tmp/scratch.tiff "
0 commit comments