Merge pull request #1220 from spevans/pr_fix_test_imports
diff --git a/Foundation/JSONEncoder.swift b/Foundation/JSONEncoder.swift
index 59a3844..ecafeed 100644
--- a/Foundation/JSONEncoder.swift
+++ b/Foundation/JSONEncoder.swift
@@ -65,7 +65,7 @@
/// The strategy to use for encoding `Data` values.
public enum DataEncodingStrategy {
/// Encoded the `Data` as a Base64-encoded string. This is the default strategy.
- case base64Encode
+ case base64
/// Encode the `Data` as a custom value encoded by the given closure.
///
@@ -88,8 +88,8 @@
/// The strategy to use in encoding dates. Defaults to `.deferredToDate`.
open var dateEncodingStrategy: DateEncodingStrategy = .deferredToDate
- /// The strategy to use in encoding binary data. Defaults to `.base64Encode`.
- open var dataEncodingStrategy: DataEncodingStrategy = .base64Encode
+ /// The strategy to use in encoding binary data. Defaults to `.base64`.
+ open var dataEncodingStrategy: DataEncodingStrategy = .base64
/// The strategy to use in encoding non-conforming numbers. Defaults to `.throw`.
open var nonConformingFloatEncodingStrategy: NonConformingFloatEncodingStrategy = .throw
@@ -672,7 +672,7 @@
fileprivate func box(_ data: Data) throws -> NSObject {
switch self.options.dataEncodingStrategy {
- case .base64Encode:
+ case .base64:
return NSString(string: data.base64EncodedString())
case .custom(let closure):
@@ -827,7 +827,7 @@
/// The strategy to use for decoding `Data` values.
public enum DataDecodingStrategy {
/// Decode the `Data` from a Base64-encoded string. This is the default strategy.
- case base64Decode
+ case base64
/// Decode the `Data` as a custom value decoded by the given closure.
case custom((_ decoder: Decoder) throws -> Data)
@@ -845,8 +845,8 @@
/// The strategy to use in decoding dates. Defaults to `.deferredToDate`.
open var dateDecodingStrategy: DateDecodingStrategy = .deferredToDate
- /// The strategy to use in decoding binary data. Defaults to `.base64Decode`.
- open var dataDecodingStrategy: DataDecodingStrategy = .base64Decode
+ /// The strategy to use in decoding binary data. Defaults to `.base64`.
+ open var dataDecodingStrategy: DataDecodingStrategy = .base64
/// The strategy to use in decoding non-conforming numbers. Defaults to `.throw`.
open var nonConformingFloatDecodingStrategy: NonConformingFloatDecodingStrategy = .throw
@@ -2042,7 +2042,7 @@
guard !(value is NSNull) else { return nil }
switch self.options.dataDecodingStrategy {
- case .base64Decode:
+ case .base64:
guard let string = value as? String else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
diff --git a/Foundation/NSKeyedUnarchiver.swift b/Foundation/NSKeyedUnarchiver.swift
index b977cc8..d75a664 100644
--- a/Foundation/NSKeyedUnarchiver.swift
+++ b/Foundation/NSKeyedUnarchiver.swift
@@ -86,7 +86,7 @@
return root
}
- public convenience init(forReadingWithData data: Data) {
+ public convenience init(forReadingWith data: Data) {
self.init(stream: Stream.data(data))
}
@@ -863,7 +863,7 @@
}
open class func unarchiveTopLevelObjectWithData(_ data: Data) throws -> Any? {
- let keyedUnarchiver = NSKeyedUnarchiver(forReadingWithData: data)
+ let keyedUnarchiver = NSKeyedUnarchiver(forReadingWith: data)
let root = try keyedUnarchiver.decodeTopLevelObject(forKey: NSKeyedArchiveRootObjectKey)
keyedUnarchiver.finishDecoding()
return root
diff --git a/Foundation/NSString.swift b/Foundation/NSString.swift
index 54fe91f..26c45b5 100644
--- a/Foundation/NSString.swift
+++ b/Foundation/NSString.swift
@@ -1221,18 +1221,6 @@
free(bytes)
}
}
-
- public convenience init?(CString nullTerminatedCString: UnsafePointer<Int8>, encoding: UInt) {
- guard let cf = CFStringCreateWithCString(kCFAllocatorSystemDefault, nullTerminatedCString, CFStringConvertNSStringEncodingToEncoding(encoding)) else {
- return nil
- }
- var str: String?
- if String._conditionallyBridgeFromObjectiveC(cf._nsObject, result: &str) {
- self.init(str!)
- } else {
- return nil
- }
- }
public convenience init(contentsOf url: URL, encoding enc: UInt) throws {
let readResult = try NSData(contentsOf: url, options: [])
diff --git a/TestFoundation/TestJSONEncoder.swift b/TestFoundation/TestJSONEncoder.swift
index 842eb52..76dc81a 100644
--- a/TestFoundation/TestJSONEncoder.swift
+++ b/TestFoundation/TestJSONEncoder.swift
@@ -446,8 +446,8 @@
outputFormatting: JSONEncoder.OutputFormatting = [],
dateEncodingStrategy: JSONEncoder.DateEncodingStrategy = .deferredToDate,
dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate,
- dataEncodingStrategy: JSONEncoder.DataEncodingStrategy = .base64Encode,
- dataDecodingStrategy: JSONDecoder.DataDecodingStrategy = .base64Decode,
+ dataEncodingStrategy: JSONEncoder.DataEncodingStrategy = .base64,
+ dataDecodingStrategy: JSONDecoder.DataDecodingStrategy = .base64,
nonConformingFloatEncodingStrategy: JSONEncoder.NonConformingFloatEncodingStrategy = .throw,
nonConformingFloatDecodingStrategy: JSONDecoder.NonConformingFloatDecodingStrategy = .throw) where T : Codable, T : Equatable {
var payload: Data! = nil
diff --git a/TestFoundation/TestNSKeyedArchiver.swift b/TestFoundation/TestNSKeyedArchiver.swift
index 32fd2b6..1a03419 100644
--- a/TestFoundation/TestNSKeyedArchiver.swift
+++ b/TestFoundation/TestNSKeyedArchiver.swift
@@ -118,7 +118,7 @@
XCTAssertTrue(encode(archiver))
archiver.finishEncoding()
- let unarchiver = NSKeyedUnarchiver(forReadingWithData: Data._unconditionallyBridgeFromObjectiveC(data))
+ let unarchiver = NSKeyedUnarchiver(forReadingWith: Data._unconditionallyBridgeFromObjectiveC(data))
XCTAssertTrue(decode(unarchiver))
// Archiving using the default initializer
@@ -127,10 +127,10 @@
XCTAssertTrue(encode(archiver1))
let archivedData = archiver1.encodedData
- let unarchiver1 = NSKeyedUnarchiver(forReadingWithData: archivedData)
+ let unarchiver1 = NSKeyedUnarchiver(forReadingWith: archivedData)
XCTAssertTrue(decode(unarchiver1))
}
-
+
private func test_archive(_ object: Any, classes: [AnyClass], allowsSecureCoding: Bool = true, outputFormat: PropertyListSerialization.PropertyListFormat) {
test_archive({ archiver -> Bool in
archiver.requiresSecureCoding = allowsSecureCoding
diff --git a/TestFoundation/TestNSString.swift b/TestFoundation/TestNSString.swift
index 33177ca..70e9398 100644
--- a/TestFoundation/TestNSString.swift
+++ b/TestFoundation/TestNSString.swift
@@ -265,21 +265,21 @@
func test_FromNullTerminatedCStringInASCII() {
let bytes = mockASCIIStringBytes + [0x00]
- let string = NSString(CString: bytes.map { Int8(bitPattern: $0) }, encoding: String.Encoding.ascii.rawValue)
+ let string = NSString(cString: bytes.map { Int8(bitPattern: $0) }, encoding: String.Encoding.ascii.rawValue)
XCTAssertNotNil(string)
XCTAssertTrue(string?.isEqual(to: mockASCIIString) ?? false)
}
func test_FromNullTerminatedCStringInUTF8() {
let bytes = mockUTF8StringBytes + [0x00]
- let string = NSString(CString: bytes.map { Int8(bitPattern: $0) }, encoding: String.Encoding.utf8.rawValue)
+ let string = NSString(cString: bytes.map { Int8(bitPattern: $0) }, encoding: String.Encoding.utf8.rawValue)
XCTAssertNotNil(string)
XCTAssertTrue(string?.isEqual(to: mockUTF8String) ?? false)
}
func test_FromMalformedNullTerminatedCStringInUTF8() {
let bytes = mockMalformedUTF8StringBytes + [0x00]
- let string = NSString(CString: bytes.map { Int8(bitPattern: $0) }, encoding: String.Encoding.utf8.rawValue)
+ let string = NSString(cString: bytes.map { Int8(bitPattern: $0) }, encoding: String.Encoding.utf8.rawValue)
XCTAssertNil(string)
}