Skip to content

Commit f45565c

Browse files
committed
StdlibUnittest: add a new overload of expectEqual()
1 parent 4f77945 commit f45565c

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ public func expectEqual<T : Equatable, U : Equatable, V : Equatable>(
150150
expectEqualTest(expected.2, actual.2, ${trace}, showFrame: false) {$0 == $1}
151151
}
152152

153+
public func expectEqual<T : Equatable, U : Equatable, V : Equatable, W : Equatable>(
154+
_ expected: (T, U, V, W), _ actual: (T, U, V, W), ${TRACE}) {
155+
expectEqualTest(expected.0, actual.0, ${trace}, showFrame: false) {$0 == $1}
156+
expectEqualTest(expected.1, actual.1, ${trace}, showFrame: false) {$0 == $1}
157+
expectEqualTest(expected.2, actual.2, ${trace}, showFrame: false) {$0 == $1}
158+
expectEqualTest(expected.3, actual.3, ${trace}, showFrame: false) {$0 == $1}
159+
}
160+
153161
public func expectationFailure(
154162
_ reason: String,
155163
trace message: String,

validation-test/StdlibUnittest/Assertions.swift.gyb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,5 +219,36 @@ AssertionsTestSuite.test("expectEqual<T : Equatable, U : Equatable, V : Equatabl
219219
}
220220
}
221221

222+
AssertionsTestSuite.test("expectEqual<T : Equatable, U : Equatable, V : Equatable, W : Equatable>") {
223+
let _0 = MinimalEquatableValue(0)
224+
let _1 = MinimalEquatableValue(1)
225+
226+
for a in [_0, _1] {
227+
for b in [_0, _1] {
228+
for c in [_0, _1] {
229+
for d in [_0, _1] {
230+
for e in [_0, _1] {
231+
for f in [_0, _1] {
232+
for g in [_0, _1] {
233+
for h in [_0, _1] {
234+
let lhs = (a, b, c, d)
235+
let rhs = (e, f, g, h)
236+
if lhs == rhs {
237+
expectEqual(lhs, rhs)
238+
} else {
239+
expectFailure {
240+
expectEqual(lhs, rhs)
241+
}
242+
}
243+
}
244+
}
245+
}
246+
}
247+
}
248+
}
249+
}
250+
}
251+
}
252+
222253
runAllTests()
223254

0 commit comments

Comments
 (0)