Skip to content

Commit bb43504

Browse files
committed
Merge pull request #7 from mattrajca/master
XCTAssertEqualWithAccuracy behavor does not match true XCTest.framework
2 parents b72cb6a + ce4c98b commit bb43504

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

XCTest/XCTest.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public func XCTAssertEqual<T, U : Equatable>(@autoclosure expression1: () -> [T
177177
}
178178

179179
public func XCTAssertEqualWithAccuracy<T : FloatingPointType>(@autoclosure expression1: () -> T, @autoclosure _ expression2: () -> T, accuracy: T, _ message: String = "", file: StaticString = __FILE__, line: UInt = __LINE__) {
180-
XCTAssert(expression1().distanceTo(expression2()) <= accuracy.distanceTo(T(0)), message, file: file, line: line)
180+
XCTAssert(abs(expression1().distanceTo(expression2())) <= abs(accuracy.distanceTo(T(0))), message, file: file, line: line)
181181
}
182182

183183
public func XCTAssertFalse(@autoclosure expression: () -> BooleanType, _ message: String = "", file: StaticString = __FILE__, line: UInt = __LINE__) {
@@ -225,7 +225,7 @@ public func XCTAssertNotEqual<T, U : Equatable>(@autoclosure expression1: () ->
225225
}
226226

227227
public func XCTAssertNotEqualWithAccuracy<T : FloatingPointType>(@autoclosure expression1: () -> T, @autoclosure _ expression2: () -> T, _ accuracy: T, _ message: String = "", file: StaticString = __FILE__, line: UInt = __LINE__) {
228-
XCTAssert(expression1().distanceTo(expression2()) > accuracy.distanceTo(T(0)), message, file: file, line: line)
228+
XCTAssert(abs(expression1().distanceTo(expression2())) > abs(accuracy.distanceTo(T(0))), message, file: file, line: line)
229229
}
230230

231231
public func XCTAssertNotNil(@autoclosure expression: () -> Any?, _ message: String = "", file: StaticString = __FILE__, line: UInt = __LINE__) {

0 commit comments

Comments
 (0)