Checks v0.1.0
Expect
pub func Expect(
condition: bool,
message: char8[..]
) -> ! TestFailure
Fails unless condition holds.
Parameters
| Name | Type | Description |
|---|---|---|
condition | bool | what must be true |
message | char8[..] | what it means, for the failure |
Returns: nothing, or the failure
ExpectEqual<T>
pub func ExpectEqual<T: Display>(
actual: T,
expected: T
) -> ! TestFailure
Fails unless actual equals expected, saying both.
Type parameters
| Name | Description |
|---|---|
T: Display | a type with == that can be displayed |
Parameters
| Name | Type | Description |
|---|---|---|
actual | T | what the code gave |
expected | T | what it should have given |
Returns: nothing, or the failure
ExpectNotEqual<T>
pub func ExpectNotEqual<T: Display>(
actual: T,
unexpected: T
) -> ! TestFailure
Fails if actual equals unexpected.
Type parameters
| Name | Description |
|---|---|
T: Display | a type with == that can be displayed |
Parameters
| Name | Type | Description |
|---|---|---|
actual | T | what the code gave |
unexpected | T | what it should not have given |
Returns: nothing, or the failure
ExpectNear
pub func ExpectNear(
actual: float64,
expected: float64,
tolerance: float64
) -> ! TestFailure
Fails unless actual is within tolerance of expected.
Parameters
| Name | Type | Description |
|---|---|---|
actual | float64 | what the code gave |
expected | float64 | what it should have given |
tolerance | float64 | how far apart they may be |
Returns: nothing, or the failure
ExpectText
pub func ExpectText(
actual: char8[..],
expected: char8[..]
) -> ! TestFailure
Fails unless actual is the same text as expected, saying at which byte they part and showing each around it.
Parameters
| Name | Type | Description |
|---|---|---|
actual | char8[..] | what the code gave |
expected | char8[..] | what it should have given |
Returns: nothing, or the failure
ExpectSome<T>
pub func ExpectSome<T>(
value: T?,
message: char8[..]
) -> T ! TestFailure
The value of value, failing when there is none.
Type parameters
| Name | Description |
|---|---|
T | the value's type |
Parameters
| Name | Type | Description |
|---|---|---|
value | T? | the optional value |
message | char8[..] | what its absence means, for the failure |
Returns: the value, or the failure
ExpectNone<T>
pub func ExpectNone<T>(
value: T?,
message: char8[..]
) -> ! TestFailure
Fails when value is present.
Type parameters
| Name | Description |
|---|---|
T | the value's type |
Parameters
| Name | Type | Description |
|---|---|---|
value | T? | the optional value |
message | char8[..] | what its presence means, for the failure |
Returns: nothing, or the failure
ExpectSuccess<T, E>
pub func ExpectSuccess<T, E>(
outcome: T ! E,
message: char8[..]
) -> T ! TestFailure
The success of outcome, failing when it failed.
Type parameters
| Name | Description |
|---|---|
T | the success's type |
E | the failure's type |
Parameters
| Name | Type | Description |
|---|---|---|
outcome | T ! E | what the code gave |
message | char8[..] | what its failure means, for the test's failure |
Returns: the success, or the failure
ExpectFailure<T, E>
pub func ExpectFailure<T, E>(
outcome: T ! E,
message: char8[..]
) -> E ! TestFailure
The failure of outcome, failing the test when it succeeded.
Type parameters
| Name | Description |
|---|---|
T | the success's type |
E | the failure's type |
Parameters
| Name | Type | Description |
|---|---|---|
outcome | T ! E | what the code gave |
message | char8[..] | what its success means, for the test's failure |
Returns: the failure the code gave, or the test's failure