Skip to content

Commit 7d6a2be

Browse files
Merge pull request #24 from ZevEisenberg/patch-1
Tweak readme
2 parents 686d090 + 03ffa18 commit 7d6a2be

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,31 @@ Add `.package(name: "Difference", url: "https://github.com/krzysztofzablocki/Dif
3131

3232
## Using lldb
3333

34-
Just write the following to see the difference between 2 instances:
34+
Write the following to see the difference between 2 instances:
3535

3636
`po dumpDiff(expected, received)`
3737

3838

3939
## Integrate with XCTest
40-
Just add this to your test target:
40+
Add this to your test target:
4141

4242
```swift
43-
public func XCTAssertEqual<T: Equatable>(_ expected: T, _ received: T, file: StaticString = #file, line: UInt = #line) {
44-
XCTAssertTrue(expected == received, "Found difference for \n" + diff(expected, received).joined(separator: ", "), file: file, line: line)
43+
public func XCTAssertEqual<T: Equatable>(_ expected: @autoclosure () throws -> T, _ received: @autoclosure () throws -> T, file: StaticString = #filePath, line: UInt = #line) {
44+
do {
45+
let expected = try expected()
46+
let received = try received()
47+
XCTAssertTrue(expected == received, "Found difference for \n" + diff(expected, received).joined(separator: ", "), file: file, line: line)
48+
}
49+
catch {
50+
XCTFail("Caught error while testing: \(error)", file: file, line: line)
51+
}
4552
}
4653
```
4754

48-
Replace `#file` with `#filePath` if you're using Xcode 12+.
55+
Replace `#filePath` with `#file` if you're using Xcode 11 or earlier.
4956

5057
## Integrate with Quick
51-
Just add this to your test target:
58+
Add this to your test target:
5259

5360
```swift
5461
public func equalDiff<T: Equatable>(_ expectedValue: T?) -> Predicate<T> {

0 commit comments

Comments
 (0)