Skip to content

Commit 8cd65b3

Browse files
committed
Add some more examples to the pointwise! documentation.
These examples clarify that the second argument may be a `Vec` and not just an array. They also show how one can use the matcher with other actual value types.
1 parent be4e5d2 commit 8cd65b3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

googletest/src/matchers/pointwise_matcher.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use googletest::*;
3131
/// # fn should_pass() -> Result<()> {
3232
/// let value = vec![1, 2, 3];
3333
/// verify_that!(value, pointwise!(le, [1, 3, 3]))?; // Passes
34+
/// verify_that!(value, pointwise!(le, vec![1, 3, 3]))?; // Passes
3435
/// # Ok(())
3536
/// # }
3637
/// # fn should_fail() -> Result<()> {
@@ -84,6 +85,17 @@ use googletest::*;
8485
/// The actual value must be a container implementing [`IntoIterator`]. This
8586
/// includes standard containers, slices (when dereferenced) and arrays.
8687
///
88+
/// ```
89+
/// # use googletest::{matchers::le, pointwise, verify_that, Result};
90+
/// # fn should_pass() -> Result<()> {
91+
/// let value = vec![1, 2, 3];
92+
/// verify_that!(*value.as_slice(), pointwise!(le, [1, 3, 3]))?; // Passes
93+
/// verify_that!([1, 2, 3], pointwise!(le, [1, 3, 3]))?; // Passes
94+
/// # Ok(())
95+
/// # }
96+
/// # should_pass().unwrap();
97+
/// ```
98+
///
8799
/// This matcher does not support matching directly against an [`Iterator`]. To
88100
/// match against an iterator, use [`Iterator::collect`] to build a [`Vec`]
89101
/// first.

0 commit comments

Comments
 (0)