v0.11.0
Pre-release
Pre-release
API Changes
-
The Minimum Rust Supported Version was updated from 1.59 to 1.66
-
The
property!andmatches_pattern!matchers use*instead ofrefto handle properties returned by reference.
For instance, to match the following structure:struct Strukt { a_field: i32 } impl Strukt { fn get_a_field(&self) -> &i32 {&self.a_field} }OLD:
verify_that(Strukt{a_field: 123}, property!(ref Strukt.get_a_field(), eq(123))NEW:
verify_that(Strukt{a_field: 123}, property!(*Strukt.get_a_field(), eq(123)) -
Macro matchers are not exported on the top level anymore but exported in the
googletest::matchersmodule as well as thegoogletest::preludemodule.
OLD:use googletest::elements_are; verify_that(vec![1,2,3], elements_are![1,2,3])NEW:
use googletest::matchers::elements_are; verify_that(vec![1,2,3], elements_are![1,2,3]) -
Matcher::explain_matchandMatcher::describenow returns aDescriptioninstead of aString. Handling of wrapping matcher motivated this change and will make them simpler to write. For simple matchers, this change should be straightforward.
OLD:impl Matcher for MyMatcher { ... fn explain_match(&self, actual: &Self::Actual) -> String { "explanation".to_string() } fn describe(&self) -> String { "description".to_string() } }NEW:
impl Matcher for MyMatcher { ... fn explain_match(&self, actual: &Self::Actual) -> Description { "explanation".into() } fn describe(&self) -> Description { "description".into() } }
Other new features and improvements
is_utf8_string(...)is a new matcher which matches a byte array with proper ut8 encoding.assert_that!andexpect_that!accepts an error message as third argument, likeassert_eq!(...).- Trailing commas support in
assert_that!,expect_that!,elements_are!, andunordered_elements_are! - Diff summary will highlight the mismatching line with colors.
#[should_panic]can be used with the#[googletest::test]macro.
Other minor changes
- When using
eq(...)with different types (e.g.Stringand&str), thePartialEqrelationship has been switched. See #334 for more details. - Documentation fix in #299 and #332
- Add an extra whitespace between subsequent non-fatal failure messages.
Full Changelog: v0.10.0...v0.11.0