Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
1.5 kB · 52 lines
Swift
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253//// XCTAssertEncodable.swift// URLQueryItemCoder//// Created by Kyle Hughes on 12/29/22.//
#if canImport(Combine)import Combineimport XCTest
@testable import URLQueryItemCoder
public func XCTAssertEncoder<Encoder, Input>( _ encoder: Encoder, encodes value: Input, as expectation: @autoclosure () -> Encoder.Output, file: StaticString = #filePath, line: UInt = #line) where Encoder: TopLevelEncoder, Encoder.Output: Equatable, Input: Encodable { do { let encodedValue = try encoder.encode(value) XCTAssertEqual(encodedValue, expectation(), file: file, line: line) } catch { XCTFail(error.localizedDescription) }}
public func XCTAssertEncoder<Encoder, Input>( _ encoder: (EncodingStrategies) -> Encoder, encodes value: Input, using configuration: EncodingStrategies = .default, as expectation: (Input, EncodingStrategies) -> Encoder.Output, prepareForEqualityAssertion: (Encoder.Output) -> Encoder.Output = { $0 }, file: StaticString = #filePath, line: UInt = #line) where Encoder: TopLevelEncoder, Encoder.Output: Equatable, Input: Encodable { do { let encodedValue = try encoder(configuration).encode(value) XCTAssertEqual( prepareForEqualityAssertion(encodedValue), prepareForEqualityAssertion(expectation(value, configuration)), file: file, line: line ) } catch { XCTFail(error.localizedDescription, file: file, line: line) }}#endif