From 39909b36f599c341f2c0ca563539b27ba409275e Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Thu, 8 Sep 2022 11:08:09 +0200 Subject: [PATCH] Fix crash "call to deleted method" when running tests on Xcode 14 --- Sources/XXClient/Helpers/JSONDecoder.swift | 4 ++-- Sources/XXClient/Helpers/JSONEncoder.swift | 4 ++-- Tests/XXClientTests/Helpers/JSONDecoderTests.swift | 2 +- Tests/XXClientTests/Helpers/JSONEncoderTests.swift | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/XXClient/Helpers/JSONDecoder.swift b/Sources/XXClient/Helpers/JSONDecoder.swift index 751a8b39..52de4ec8 100644 --- a/Sources/XXClient/Helpers/JSONDecoder.swift +++ b/Sources/XXClient/Helpers/JSONDecoder.swift @@ -8,14 +8,14 @@ class JSONDecoder: Foundation.JSONDecoder { override func decode<T>(_ type: T.Type, from data: Data) throws -> T where T: Decodable { do { - let data = convertNumberToString(in: data, at: "Value") + let data = Self.convertNumberToString(in: data, at: "Value") return try super.decode(type, from: data) } catch { throw JSONDecodingError(error, data: data) } } - func convertNumberToString( + static func convertNumberToString( in input: Data, at key: String ) -> Data { diff --git a/Sources/XXClient/Helpers/JSONEncoder.swift b/Sources/XXClient/Helpers/JSONEncoder.swift index 69b36859..cecc558e 100644 --- a/Sources/XXClient/Helpers/JSONEncoder.swift +++ b/Sources/XXClient/Helpers/JSONEncoder.swift @@ -9,14 +9,14 @@ class JSONEncoder: Foundation.JSONEncoder { override func encode<T>(_ value: T) throws -> Data where T: Encodable { do { var data = try super.encode(value) - data = convertStringToNumber(in: data, at: "Value") + data = Self.convertStringToNumber(in: data, at: "Value") return data } catch { throw JSONEncodingError(error, value: value) } } - func convertStringToNumber( + static func convertStringToNumber( in input: Data, at key: String ) -> Data { diff --git a/Tests/XXClientTests/Helpers/JSONDecoderTests.swift b/Tests/XXClientTests/Helpers/JSONDecoderTests.swift index 16f2afcb..b5d3b286 100644 --- a/Tests/XXClientTests/Helpers/JSONDecoderTests.swift +++ b/Tests/XXClientTests/Helpers/JSONDecoderTests.swift @@ -71,7 +71,7 @@ private func assertConvertingNumberToString( ) { XCTAssertNoDifference( String( - data: JSONDecoder().convertNumberToString( + data: JSONDecoder.convertNumberToString( in: input.data(using: .utf8)!, at: key ), diff --git a/Tests/XXClientTests/Helpers/JSONEncoderTests.swift b/Tests/XXClientTests/Helpers/JSONEncoderTests.swift index 58fbfae7..b583207e 100644 --- a/Tests/XXClientTests/Helpers/JSONEncoderTests.swift +++ b/Tests/XXClientTests/Helpers/JSONEncoderTests.swift @@ -71,7 +71,7 @@ private func assertConvertingStringToNumber( ) { XCTAssertNoDifference( String( - data: JSONEncoder().convertStringToNumber( + data: JSONEncoder.convertStringToNumber( in: input.data(using: .utf8)!, at: key ), -- GitLab