Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions googletest/crate_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand All @@ -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. |
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion googletest/src/assertions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
/// # }
/// ```
Expand Down
20 changes: 13 additions & 7 deletions googletest/src/matchers/empty_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,21 @@ use std::fmt::Debug;
/// # use std::collections::HashSet;
/// # fn should_pass() -> Result<()> {
/// let value: Vec<i32> = vec![];
/// verify_that!(value, empty())?;
/// verify_that!(value, is_empty())?;
/// let value: HashSet<i32> = 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
}
Expand Down Expand Up @@ -67,24 +73,24 @@ mod tests {
#[test]
fn empty_matcher_match_empty_vec() -> Result<()> {
let value: Vec<i32> = 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<i32> = HashSet::new();
verify_that!(value, empty())
verify_that!(value, is_empty())
}
}
2 changes: 1 addition & 1 deletion googletest/src/matchers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
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};

Check warning on line 73 in googletest/src/matchers/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

use of deprecated function `matchers::empty_matcher::empty`: Use `is_empty()` instead.

warning: use of deprecated function `matchers::empty_matcher::empty`: Use `is_empty()` instead. --> googletest/src/matchers/mod.rs:73:25 | 73 | pub use empty_matcher::{empty, is_empty}; | ^^^^^ | = note: `#[warn(deprecated)]` on by default

Check warning on line 73 in googletest/src/matchers/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

use of deprecated function `matchers::empty_matcher::empty`: Use `is_empty()` instead.

warning: use of deprecated function `matchers::empty_matcher::empty`: Use `is_empty()` instead. --> googletest/src/matchers/mod.rs:73:25 | 73 | pub use empty_matcher::{empty, is_empty}; | ^^^^^ | = note: `#[warn(deprecated)]` on by default
pub use eq_matcher::{eq, EqMatcher};
pub use err_matcher::err;
pub use ge_matcher::ge;
Expand Down