#matcher #predicates #googletest #convert #docs #latest #foo

googletest-predicates

Provides a function to convert googletest matchers (https://docs.rs/googletest/latest/googletest/) into predicates (https://docs.rs/predicates/latest/predicates)

5 releases (3 breaking)

0.4.0 Sep 16, 2023
0.3.0 Sep 16, 2023
0.2.0 Feb 6, 2023
0.1.1 Jan 3, 2023
0.1.0 Jan 3, 2023

#7 in #predicates

MIT license

5KB
90 lines

googletest-predicates

Provides a function to convert googletest matchers into predicates. This enables you to write write your rich matcher logic using the googletest library and reuse it in other libraries which expect predicates.

For example, when using mockall for mocking types, you can use the googletest matcher, eq by wrapping it in the matcher function provided by this library:

use googletest::{expect_that, matchers::*};
use googletest_predicates::matcher;

let mut mock = MockMyTrait::new();
mock.expect_foo()
    .with(matcher(eq(1)))
    .times(1)
    .returning(|x| x + 1);
expect_that!(mock.foo(1), eq(2))

Dependencies

~3–4.5MB
~86K SLoC