Skip to content

v0.11.0

Pre-release
Pre-release
Compare
Choose a tag to compare
@bjacotg bjacotg released this 12 Jan 11:03
· 151 commits to main since this release

API Changes

  • The Minimum Rust Supported Version was updated from 1.59 to 1.66

  • The property! and matches_pattern! matchers use * instead of ref to 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::matchers module as well as the googletest::prelude module.
    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_match and Matcher::describe now returns a Description instead of a String. 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! and expect_that! accepts an error message as third argument, like assert_eq!(...).
  • Trailing commas support in assert_that!, expect_that!, elements_are!, and unordered_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. String and &str), the PartialEq relationship 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