Skip to content

Commit

Permalink
Show URLFormCoding test case errors in test case
Browse files Browse the repository at this point in the history
  • Loading branch information
mredig committed Jan 15, 2025
1 parent f377115 commit 69f69e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
12 changes: 9 additions & 3 deletions Tests/HummingbirdTests/URLEncodedForm/URLDecoderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@ import XCTest
@testable import Hummingbird

final class URLDecodedFormDecoderTests: XCTestCase {
func testForm<Input: Decodable & Equatable>(_ value: Input, query: String, decoder: URLEncodedFormDecoder = .init()) {
func testForm<Input: Decodable & Equatable>(
_ value: Input,
query: String,
decoder: URLEncodedFormDecoder = .init(),
file: StaticString = #filePath,
line: UInt = #line
) {
do {
let value2 = try decoder.decode(Input.self, from: query)
XCTAssertEqual(value, value2)
XCTAssertEqual(value, value2, file: file, line: line)
} catch {
XCTFail("\(error)")
XCTFail("\(error)", file: file, line: line)
}
}

Expand Down
10 changes: 5 additions & 5 deletions Tests/HummingbirdTests/URLEncodedForm/URLEncoderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ import Hummingbird
import XCTest

final class URLEncodedFormEncoderTests: XCTestCase {
static func XCTAssertEncodedEqual(_ lhs: String, _ rhs: String) {
static func XCTAssertEncodedEqual(_ lhs: String, _ rhs: String, file: StaticString = #filePath, line: UInt = #line) {
let lhs = lhs.split(separator: "&")
.sorted { $0 < $1 }
.joined(separator: "&")
let rhs = rhs.split(separator: "&")
.sorted { $0 < $1 }
.joined(separator: "&")
XCTAssertEqual(lhs, rhs)
XCTAssertEqual(lhs, rhs, file: file, line: line)
}

func testForm(_ value: some Encodable, query: String, encoder: URLEncodedFormEncoder = .init()) {
func testForm(_ value: some Encodable, query: String, encoder: URLEncodedFormEncoder = .init(), file: StaticString = #filePath, line: UInt = #line) {
do {
let query2 = try encoder.encode(value)
Self.XCTAssertEncodedEqual(query2, query)
Self.XCTAssertEncodedEqual(query2, query, file: file, line: line)
} catch {
XCTFail("\(error)")
XCTFail("\(error)", file: file, line: line)
}
}

Expand Down

0 comments on commit 69f69e8

Please sign in to comment.