dream_test/matchers/comparison
Comparison matchers for dream_test.
These matchers compare numeric values and are re-exported through
dream_test/matchers.
Use them to assert ordering relationships (greater-than, less-than, in a range, etc.) while preserving the numeric value for further chaining.
Example
10
|> should
|> be_greater_than(0)
|> or_fail_with("expected 10 to be greater than 0")
Values
pub fn be_at_least(
value_or_result value_or_result: types.MatchResult(Int),
minimum minimum: Int,
) -> types.MatchResult(Int)
Assert that an integer is at least a minimum value (>=).
Parameters
value_or_result: theMatchResult(Int)produced byshould(or a previous matcher)minimum: the minimum allowed value (inclusive)
Returns
A MatchResult(Int) preserving the integer for further chaining.
Example
10
|> should
|> be_at_least(10)
|> or_fail_with("expected 10 to be at least 10")
pub fn be_at_most(
value_or_result value_or_result: types.MatchResult(Int),
maximum maximum: Int,
) -> types.MatchResult(Int)
Assert that an integer is at most a maximum value (<=).
Parameters
value_or_result: theMatchResult(Int)produced byshould(or a previous matcher)maximum: the maximum allowed value (inclusive)
Returns
A MatchResult(Int) preserving the integer for further chaining.
Example
10
|> should
|> be_at_most(10)
|> or_fail_with("expected 10 to be at most 10")
pub fn be_between(
value_or_result value_or_result: types.MatchResult(Int),
min min: Int,
max max: Int,
) -> types.MatchResult(Int)
Assert that an integer is between two values (exclusive).
The value must be strictly greater than min and strictly less than max.
Parameters
value_or_result: theMatchResult(Int)produced byshould(or a previous matcher)min: lower bound (exclusive)max: upper bound (exclusive)
Returns
A MatchResult(Int) preserving the integer for further chaining.
Example
5
|> should
|> be_between(1, 10)
|> or_fail_with("expected 5 to be between 1 and 10")
pub fn be_greater_than(
value_or_result value_or_result: types.MatchResult(Int),
threshold threshold: Int,
) -> types.MatchResult(Int)
Assert that an integer is greater than a threshold.
Parameters
value_or_result: theMatchResult(Int)produced byshould(or a previous matcher)threshold: the value the actual integer must be greater than
Returns
A MatchResult(Int) preserving the integer for further chaining.
Example
10
|> should
|> be_greater_than(0)
|> or_fail_with("expected 10 to be greater than 0")
pub fn be_greater_than_float(
value_or_result value_or_result: types.MatchResult(Float),
threshold threshold: Float,
) -> types.MatchResult(Float)
Assert that a float is greater than a threshold.
Parameters
value_or_result: theMatchResult(Float)produced byshould(or a previous matcher)threshold: the value the actual float must be greater than
Returns
A MatchResult(Float) preserving the float for further chaining.
Example
0.5
|> should
|> be_greater_than_float(0.0)
|> or_fail_with("expected 0.5 to be greater than 0.0")
pub fn be_in_range(
value_or_result value_or_result: types.MatchResult(Int),
min min: Int,
max max: Int,
) -> types.MatchResult(Int)
Assert that an integer is within a range (inclusive).
The value must be >= min and <= max.
Parameters
value_or_result: theMatchResult(Int)produced byshould(or a previous matcher)min: lower bound (inclusive)max: upper bound (inclusive)
Returns
A MatchResult(Int) preserving the integer for further chaining.
Example
10
|> should
|> be_in_range(0, 100)
|> or_fail_with("expected 10 to be in range 0..100")
pub fn be_less_than(
value_or_result value_or_result: types.MatchResult(Int),
threshold threshold: Int,
) -> types.MatchResult(Int)
Assert that an integer is less than a threshold.
Parameters
value_or_result: theMatchResult(Int)produced byshould(or a previous matcher)threshold: the value the actual integer must be less than
Returns
A MatchResult(Int) preserving the integer for further chaining.
Example
10
|> should
|> be_less_than(100)
|> or_fail_with("expected 10 to be less than 100")
pub fn be_less_than_float(
value_or_result value_or_result: types.MatchResult(Float),
threshold threshold: Float,
) -> types.MatchResult(Float)
Assert that a float is less than a threshold.
Parameters
value_or_result: theMatchResult(Float)produced byshould(or a previous matcher)threshold: the value the actual float must be less than
Returns
A MatchResult(Float) preserving the float for further chaining.
Example
0.5
|> should
|> be_less_than_float(1.0)
|> or_fail_with("expected 0.5 to be less than 1.0")