-
Notifications
You must be signed in to change notification settings - Fork 26
Closed
Description
Hello!
I just realized that some of my tests pass, even when they shouldn't. The use matches_pattern! and look like this:
#[gtest]
fn test_with_wildcard() {
let result: Option<i8> = None;
expect_that!(result, matches_pattern!(Some(_)));
}
#[gtest]
fn test_with_value() {
let result: Option<i8> = None;
expect_that!(result, matches_pattern!(Some(123)));
}The test_with_wildcard compiles and passes:
% cargo test
Finished `test` profile [unoptimized + debuginfo] target(s) in 0.08s
Running unittests src/lib.rs (target/debug/deps/matches_pattern-27f44d6b49ac5855)
running 2 tests
test tests::test_with_wildcard ... ok
test tests::test_with_value ... FAILED
Both test should fail: I'm matching a None against a Some(_).
Reading the documentation closely, I see it says
This macro does not support plain (non-struct) tuples.
I don't know if that is what I'm seeing here?
My actual code is more complex: I'm matching a result against a larger Error enum:
expect_that!(
result,
err(matches_pattern!(Error::InvalidInput(_)))
);Metadata
Metadata
Assignees
Labels
No labels