@@ -70,6 +70,7 @@ class TestNSString : XCTestCase {
7070 ( " test_stringByTrimmingCharactersInSet " , test_stringByTrimmingCharactersInSet) ,
7171 ( " test_initializeWithFormat " , test_initializeWithFormat) ,
7272 ( " test_initializeWithFormat2 " , test_initializeWithFormat2) ,
73+ ( " test_initializeWithFormat3 " , test_initializeWithFormat3) ,
7374 ( " test_stringByDeletingLastPathComponent " , test_stringByDeletingLastPathComponent) ,
7475 ( " test_getCString_simple " , test_getCString_simple) ,
7576 ( " test_getCString_nonASCII_withASCIIAccessor " , test_getCString_nonASCII_withASCIIAccessor) ,
@@ -612,6 +613,35 @@ class TestNSString : XCTestCase {
612613 XCTAssertEqual ( string, " 4B " )
613614 }
614615
616+ func test_initializeWithFormat3( ) {
617+ let argument : [ CVarArg ] = [ 1000 , 42.0 ]
618+
619+ withVaList ( argument) {
620+ pointer in
621+ let string = NSString ( format: " Default value is %d (%.1f) " , locale: nil , arguments: pointer)
622+ XCTAssertEqual ( string, " Default value is 1000 (42.0) " )
623+ }
624+
625+ withVaList ( argument) {
626+ pointer in
627+ let string = NSString ( format: " en_GB value is %d (%.1f) " , locale: NSLocale . init ( localeIdentifier: " en_GB " ) , arguments: pointer)
628+ XCTAssertEqual ( string, " en_GB value is 1,000 (42.0) " )
629+ }
630+
631+ withVaList ( argument) {
632+ pointer in
633+ let string = NSString ( format: " de_DE value is %d (%.1f) " , locale: NSLocale . init ( localeIdentifier: " de_DE " ) , arguments: pointer)
634+ XCTAssertEqual ( string, " de_DE value is 1.000 (42,0) " )
635+ }
636+
637+ withVaList ( argument) {
638+ pointer in
639+ let loc : NSDictionary = [ " NSDecimalSeparator " as NSString : " & " as NSString ]
640+ let string = NSString ( format: " NSDictionary value is %d (%.1f) " , locale: loc, arguments: pointer)
641+ XCTAssertEqual ( string, " NSDictionary value is 1000 (42&0) " )
642+ }
643+ }
644+
615645 func test_stringByDeletingLastPathComponent( ) {
616646 do {
617647 let path : NSString = " /tmp/scratch.tiff "
0 commit comments