diff --git a/googletest/crate_docs.md b/googletest/crate_docs.md index 0eb209a8..5345d305 100644 --- a/googletest/crate_docs.md +++ b/googletest/crate_docs.md @@ -132,7 +132,6 @@ The following matchers are provided in GoogleTest Rust: | [`displays_as`] | A [`Display`] value whose formatted string is matched by the argument. | | [`each`] | A container all of whose elements the given argument matches. | | [`elements_are!`] | A container whose elements the arguments match, in order. | -| [`empty`] | An empty collection. | | [`ends_with`] | A string ending with the given suffix. | | [`eq`] | A value equal to the argument, in the sense of the [`PartialEq`] trait. | | [`err`] | A [`Result`][std::result::Result] containing an `Err` variant the argument matches. | @@ -141,9 +140,10 @@ The following matchers are provided in GoogleTest Rust: | [`gt`] | A [`PartialOrd`] value strictly greater than the given value. | | [`has_entry`] | A [`HashMap`] containing a given key whose value the argument matches. | | [`is_contained_in!`] | A container each of whose elements is matched by some given matcher. | -| [`is_nan`] | A floating point number which is NaN. | +| [`is_empty`] | An empty collection. | | [`is_finite`] | A floating point number which is neither infinite nor NaN. | | [`is_infinite`] | A floating point number which is positive or negative infinity. | +| [`is_nan`] | A floating point number which is NaN. | | [`le`] | A [`PartialOrd`] value less than or equal to the given value. | | [`len`] | A container whose number of elements the argument matches. | | [`lt`] | A [`PartialOrd`] value strictly less than the given value. | @@ -177,7 +177,6 @@ The following matchers are provided in GoogleTest Rust: [`derefs_to`]: matchers::derefs_to [`each`]: matchers::each [`elements_are!`]: matchers::elements_are -[`empty`]: matchers::empty [`ends_with`]: matchers::ends_with [`eq`]: matchers::eq [`err`]: matchers::err @@ -186,9 +185,10 @@ The following matchers are provided in GoogleTest Rust: [`gt`]: matchers::gt [`has_entry`]: matchers::has_entry [`is_contained_in!`]: matchers::is_contained_in -[`is_nan`]: matchers::is_nan +[`is_empty`]: matchers::is_empty [`is_finite`]: matchers::is_finite [`is_infinite`]: matchers::is_infinite +[`is_nan`]: matchers::is_nan [`le`]: matchers::le [`len`]: matchers::len [`lt`]: matchers::lt diff --git a/googletest/src/assertions.rs b/googletest/src/assertions.rs index e2ca35f5..e53037e1 100644 --- a/googletest/src/assertions.rs +++ b/googletest/src/assertions.rs @@ -1656,7 +1656,7 @@ pub mod internal { /// # use googletest::prelude::*; /// # fn would_not_compile_without_autoref() -> Result<()> { /// let not_copyable = vec![1,2,3]; - /// verify_that!(not_copyable, empty())?; + /// verify_that!(not_copyable, is_empty())?; /// # Ok(()) /// # } /// ``` diff --git a/googletest/src/matchers/empty_matcher.rs b/googletest/src/matchers/empty_matcher.rs index 790b4878..f0075f74 100644 --- a/googletest/src/matchers/empty_matcher.rs +++ b/googletest/src/matchers/empty_matcher.rs @@ -29,15 +29,21 @@ use std::fmt::Debug; /// # use std::collections::HashSet; /// # fn should_pass() -> Result<()> { /// let value: Vec = vec![]; -/// verify_that!(value, empty())?; +/// verify_that!(value, is_empty())?; /// let value: HashSet = HashSet::new(); -/// verify_that!(value, empty())?; +/// verify_that!(value, is_empty())?; /// let value: &[u32] = &[]; -/// verify_that!(value, empty())?; +/// verify_that!(value, is_empty())?; /// # Ok(()) /// # } /// # should_pass().unwrap(); /// ``` +pub fn is_empty() -> EmptyMatcher { + EmptyMatcher +} + +/// This is deprecated. Use `is_empty()` instead. +#[deprecated(since = "0.14.1", note = "Use `is_empty()` instead.")] pub fn empty() -> EmptyMatcher { EmptyMatcher } @@ -67,24 +73,24 @@ mod tests { #[test] fn empty_matcher_match_empty_vec() -> Result<()> { let value: Vec = vec![]; - verify_that!(value, empty()) + verify_that!(value, is_empty()) } #[test] fn empty_matcher_does_not_match_empty_vec() -> Result<()> { let value = vec![1, 2, 3]; - verify_that!(value, not(empty())) + verify_that!(value, not(is_empty())) } #[test] fn empty_matcher_matches_empty_slice() -> Result<()> { let value: &[i32] = &[]; - verify_that!(value, empty()) + verify_that!(value, is_empty()) } #[test] fn empty_matcher_matches_empty_hash_set() -> Result<()> { let value: HashSet = HashSet::new(); - verify_that!(value, empty()) + verify_that!(value, is_empty()) } } diff --git a/googletest/src/matchers/mod.rs b/googletest/src/matchers/mod.rs index ab751d91..57b7f98e 100644 --- a/googletest/src/matchers/mod.rs +++ b/googletest/src/matchers/mod.rs @@ -70,7 +70,7 @@ pub use contains_regex_matcher::contains_regex; pub use derefs_to_matcher::derefs_to; pub use display_matcher::displays_as; pub use each_matcher::each; -pub use empty_matcher::empty; +pub use empty_matcher::{empty, is_empty}; pub use eq_matcher::{eq, EqMatcher}; pub use err_matcher::err; pub use ge_matcher::ge;