Skip to content

Commit

Permalink
NSString: Fix malformed string test and re-enable other disabled tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spevans committed Oct 15, 2017
1 parent a0f8df7 commit f1c804a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 4 additions & 1 deletion Foundation/NSString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,10 @@ open class NSString : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSC
}

public convenience init?(cString nullTerminatedCString: UnsafePointer<Int8>, encoding: UInt) {
self.init(string: CFStringCreateWithCString(kCFAllocatorSystemDefault, nullTerminatedCString, CFStringConvertNSStringEncodingToEncoding(encoding))._swiftObject)
guard let str = CFStringCreateWithCString(kCFAllocatorSystemDefault, nullTerminatedCString, CFStringConvertNSStringEncodingToEncoding(encoding)) else {
return nil
}
self.init(string: str._swiftObject)
}

internal func _fastCStringContents(_ nullTerminated: Bool) -> UnsafePointer<Int8>? {
Expand Down
9 changes: 3 additions & 6 deletions TestFoundation/TestNSString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,13 @@ class TestNSString : XCTestCase {
("test_isNotEqualToObjectWithNSNumber", test_isNotEqualToObjectWithNSNumber ),
("test_FromASCIIData", test_FromASCIIData ),
("test_FromUTF8Data", test_FromUTF8Data ),
// Swift3 updates broke the expectations of this test. disabling for now
// ("test_FromMalformedUTF8Data", test_FromMalformedUTF8Data ),
("test_FromMalformedUTF8Data", test_FromMalformedUTF8Data ),
("test_FromASCIINSData", test_FromASCIINSData ),
("test_FromUTF8NSData", test_FromUTF8NSData ),
// Swift3 updates broke the expectations of this test. disabling for now
// ("test_FromMalformedUTF8NSData", test_FromMalformedUTF8NSData ),
("test_FromMalformedUTF8NSData", test_FromMalformedUTF8NSData ),
("test_FromNullTerminatedCStringInASCII", test_FromNullTerminatedCStringInASCII ),
("test_FromNullTerminatedCStringInUTF8", test_FromNullTerminatedCStringInUTF8 ),
// Swift3 updates broke the expectations of this test. disabling for now
// ("test_FromMalformedNullTerminatedCStringInUTF8", test_FromMalformedNullTerminatedCStringInUTF8 ),
("test_FromMalformedNullTerminatedCStringInUTF8", test_FromMalformedNullTerminatedCStringInUTF8 ),
("test_uppercaseString", test_uppercaseString ),
("test_lowercaseString", test_lowercaseString ),
("test_capitalizedString", test_capitalizedString ),
Expand Down

0 comments on commit f1c804a

Please sign in to comment.