Function googletest::matchers::gt
source · pub fn gt<ActualT: Debug + PartialOrd<ExpectedT>, ExpectedT: Debug>(
expected: ExpectedT
) -> impl Matcher<ActualT = ActualT>
Expand description
Matches a value greater (in the sense of >
) than expected
.
The types of ActualT
of actual
and ExpectedT
of expected
must be
comparable via the PartialOrd
trait. Namely, ActualT
must implement
PartialOrd<ExpectedT>
.
verify_that!(38, gt(1))?; // Passes
verify_that!(234, gt(234))?; // Fails
In most cases the params neeed to be the same type or they need to be cast explicitly. This can be surprising when comparing integer types or references:
ⓘ
verify_that!(123u32, gt(0u64))?; // Does not compile
verify_that!(123u32 as u64, gt(0u64))?; // Passes
ⓘ
let actual: &u32 = &2;
let expected: u32 = 1;
verify_that!(actual, gt(expected))?; // Does not compile
let actual: &u32 = &2;
let expected: u32 = 1;
verify_that!(actual, gt(&expected))?; // Compiles and passes
You can find the standard library PartialOrd
implementation in
https://doc.rust-lang.org/core/cmp/trait.PartialOrd.html#implementors