@@ -115,15 +115,21 @@ public func ~=(patterns: [StringPattern], input: [String]) -> Bool {
115
115
return matchAny ( patterns [ ... ] , input: input [ ... ] )
116
116
}
117
117
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)
120
126
}
121
127
122
128
public func XCTAssertMatch( _ value: String , _ pattern: StringPattern , file: StaticString = #file, line: UInt = #line) {
123
129
XCTAssertMatchImpl ( pattern ~= value, value, pattern, file: file, line: line)
124
130
}
125
131
public 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)
127
133
}
128
134
129
135
public 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
134
140
}
135
141
public func XCTAssertNoMatch( _ value: String ? , _ pattern: StringPattern , file: StaticString = #file, line: UInt = #line) {
136
142
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)
138
144
}
139
145
140
146
public func XCTAssertMatch( _ value: [ String ] , _ pattern: [ StringPattern ] , file: StaticString = #file, line: UInt = #line) {
141
147
XCTAssertMatchImpl ( pattern ~= value, value, pattern, file: file, line: line)
142
148
}
143
149
public 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)
145
151
}
0 commit comments