Function XCTUnwrap(_:case:_:file:line:)
public func XCTUnwrap<Root, Case>(
_ expression: @autoclosure () throws -> Root,
case extract: (Root) -> Case?,
_ message: @autoclosure () -> String = "",
file: StaticString = #file,
line: UInt = #line
) throws -> Case
Asserts that an enum value matches a particular case and returns the associated value.
Parameters
Name | Type | Description |
---|---|---|
expression | @autoclosure () throws -> Root |
An enum value. |
extract | (Root) -> Case? |
A closure that attempts to extract a particular case from the enum. You can supply a case path literal here, like '/Enum.case'. |
message | @autoclosure () -> String |
An optional description of a failure. |
Returns
The unwrapped associated value from the matched case of the enum.