Skip to content

Commit

Permalink
Added custom assert
Browse files Browse the repository at this point in the history
  • Loading branch information
skychiarottoa committed May 3, 2021
1 parent c2f3fba commit 09a59a3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
24 changes: 0 additions & 24 deletions XCode/Sources/Asserts/Assertions.swift

This file was deleted.

23 changes: 23 additions & 0 deletions XCode/Sources/Asserts/XCAssertEquals+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,26 @@ public func assertURLEquals(_ url1: String, _ url2: String, ignores: [URLCompone
}
}
}


public func assertEquals<T>(_ expression1: @autoclosure () throws -> T,
_ expression2: @autoclosure () throws -> T,
_ message: @autoclosure () -> String = "", file: StaticString = #filePath, line: UInt = #line) where T : Equatable {
return XCTAssertEqual(try expression1(), try expression2(), message(), file: file, line: line)
}

public func assertEquals<T>(_ expression1: @autoclosure () throws -> T, _ expression2: @autoclosure () throws -> T, accuracy: T, _ message: @autoclosure () -> String = "", file: StaticString = #filePath, line: UInt = #line) where T : FloatingPoint {
return XCTAssertEqual(try expression1(), try expression2(), accuracy: accuracy, message(), file: file, line: line)
}

public func assertEquals<T>(_ expression1: @autoclosure () throws -> T, _ expression2: @autoclosure () throws -> T, accuracy: T, _ message: @autoclosure () -> String = "", file: StaticString = #filePath, line: UInt = #line) where T : Numeric {
return XCTAssertEqual(try expression1(), try expression2(), accuracy: accuracy, message(), file: file, line: line)
}

public func assertNotNull(_ expression: @autoclosure () throws -> Any?, _ message: @autoclosure () -> String = "", file: StaticString = #filePath, line: UInt = #line) {
return XCTAssertNotNil(try expression(), message(), file: file, line: line)
}

public func assertNull(_ expression: @autoclosure () throws -> Any?, _ message: @autoclosure () -> String = "", file: StaticString = #filePath, line: UInt = #line) {
return XCTAssertNil(try expression(), message(), file: file, line: line)
}

0 comments on commit 09a59a3

Please sign in to comment.