@@ -115,15 +115,21 @@ public func ~=(patterns: [StringPattern], input: [String]) -> Bool {
115115 return matchAny ( patterns [ ... ] , input: input [ ... ] )
116116}
117117
118- private func XCTAssertMatchImpl< Pattern, Value> ( _ result: Bool , _ value: Value , _ pattern: Pattern , file: StaticString , line: UInt ) {
119- XCTAssert ( result, " unexpected failure matching ' \( value) ' against pattern \( pattern) " , file: file, line: line)
118+ private func XCTAssertMatchImpl< Pattern, Value> ( _ result: Bool , _ value: Value , _ pattern: Pattern , negativeMatch: Bool = false , file: StaticString , line: UInt ) {
119+ let message : String
120+ if negativeMatch {
121+ message = " did not expect ' \( value) ' to match pattern \( pattern) "
122+ } else {
123+ message = " unexpected failure matching ' \( value) ' against pattern \( pattern) "
124+ }
125+ XCTAssert ( result, message, file: file, line: line)
120126}
121127
122128public func XCTAssertMatch( _ value: String , _ pattern: StringPattern , file: StaticString = #file, line: UInt = #line) {
123129 XCTAssertMatchImpl ( pattern ~= value, value, pattern, file: file, line: line)
124130}
125131public func XCTAssertNoMatch( _ value: String , _ pattern: StringPattern , file: StaticString = #file, line: UInt = #line) {
126- XCTAssertMatchImpl ( !( pattern ~= value) , value, pattern, file: file, line: line)
132+ XCTAssertMatchImpl ( !( pattern ~= value) , value, pattern, negativeMatch : true , file: file, line: line)
127133}
128134
129135public func XCTAssertMatch( _ value: String ? , _ pattern: StringPattern , file: StaticString = #file, line: UInt = #line) {
@@ -134,12 +140,12 @@ public func XCTAssertMatch(_ value: String?, _ pattern: StringPattern, file: Sta
134140}
135141public func XCTAssertNoMatch( _ value: String ? , _ pattern: StringPattern , file: StaticString = #file, line: UInt = #line) {
136142 guard let value = value else { return }
137- XCTAssertMatchImpl ( !( pattern ~= value) , value, pattern, file: file, line: line)
143+ XCTAssertMatchImpl ( !( pattern ~= value) , value, pattern, negativeMatch : true , file: file, line: line)
138144}
139145
140146public func XCTAssertMatch( _ value: [ String ] , _ pattern: [ StringPattern ] , file: StaticString = #file, line: UInt = #line) {
141147 XCTAssertMatchImpl ( pattern ~= value, value, pattern, file: file, line: line)
142148}
143149public func XCTAssertNoMatch( _ value: [ String ] , _ pattern: [ StringPattern ] , file: StaticString = #file, line: UInt = #line) {
144- XCTAssertMatchImpl ( !( pattern ~= value) , value, pattern, file: file, line: line)
150+ XCTAssertMatchImpl ( !( pattern ~= value) , value, pattern, negativeMatch : true , file: file, line: line)
145151}
0 commit comments