Skip to content

Commit fa6aabf

Browse files
committed
Flip the PartialEq constaint on EqMatcher
1 parent 147862d commit fa6aabf

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

googletest/src/matchers/contains_matcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ mod tests {
200200

201201
#[test]
202202
fn contains_does_not_match_empty_slice() -> Result<()> {
203-
let matcher = contains(eq(1));
203+
let matcher = contains(eq::<i32, _>(1));
204204

205205
let result = matcher.matches(&[]);
206206

googletest/src/matchers/eq_matcher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ pub struct EqMatcher<A: ?Sized, T> {
8383
phantom: PhantomData<A>,
8484
}
8585

86-
impl<A: Debug + ?Sized, T: PartialEq<A> + Debug> Matcher for EqMatcher<A, T> {
86+
impl<T: Debug, A: Debug + ?Sized + PartialEq<T>> Matcher for EqMatcher<A, T> {
8787
type ActualT = A;
8888

8989
fn matches(&self, actual: &A) -> MatcherResult {
90-
(self.expected == *actual).into()
90+
(*actual == self.expected).into()
9191
}
9292

9393
fn describe(&self, matcher_result: MatcherResult) -> Description {

googletest/src/matchers/some_matcher.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ mod tests {
104104

105105
#[test]
106106
fn some_does_not_match_option_with_none() -> Result<()> {
107-
let matcher = some(eq(1));
107+
let matcher = some(eq::<i32, _>(1));
108108

109109
let result = matcher.matches(&None);
110110

@@ -131,22 +131,22 @@ mod tests {
131131
#[test]
132132
fn some_describe_matches() -> Result<()> {
133133
verify_that!(
134-
some(eq(1)).describe(MatcherResult::Match),
134+
some(eq::<i32, _>(1)).describe(MatcherResult::Match),
135135
displays_as(eq("has a value which is equal to 1"))
136136
)
137137
}
138138

139139
#[test]
140140
fn some_describe_does_not_match() -> Result<()> {
141141
verify_that!(
142-
some(eq(1)).describe(MatcherResult::NoMatch),
142+
some(eq::<i32, _>(1)).describe(MatcherResult::NoMatch),
143143
displays_as(eq("is None or has a value which isn't equal to 1"))
144144
)
145145
}
146146

147147
#[test]
148148
fn some_explain_match_with_none() -> Result<()> {
149-
verify_that!(some(eq(1)).explain_match(&None), displays_as(eq("which is None")))
149+
verify_that!(some(eq::<i32, _>(1)).explain_match(&None), displays_as(eq("which is None")))
150150
}
151151

152152
#[test]

googletest/tests/tuple_matcher_test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ fn tuple_matcher_with_trailing_comma_matches_matching_12_tuple() -> Result<()> {
176176
#[test]
177177
fn tuple_matcher_1_has_correct_description_for_match() -> Result<()> {
178178
verify_that!(
179-
(eq(1),).describe(MatcherResult::Match),
179+
(eq::<i32, _>(1),).describe(MatcherResult::Match),
180180
displays_as(eq(indoc!(
181181
"
182182
is a tuple whose values respectively match:
@@ -188,7 +188,7 @@ fn tuple_matcher_1_has_correct_description_for_match() -> Result<()> {
188188
#[test]
189189
fn tuple_matcher_1_has_correct_description_for_mismatch() -> Result<()> {
190190
verify_that!(
191-
(eq(1),).describe(MatcherResult::NoMatch),
191+
(eq::<i32, _>(1),).describe(MatcherResult::NoMatch),
192192
displays_as(eq(indoc!(
193193
"
194194
is a tuple whose values do not respectively match:
@@ -200,7 +200,7 @@ fn tuple_matcher_1_has_correct_description_for_mismatch() -> Result<()> {
200200
#[test]
201201
fn tuple_matcher_2_has_correct_description_for_match() -> Result<()> {
202202
verify_that!(
203-
(eq(1), eq(2)).describe(MatcherResult::Match),
203+
(eq::<i32, _>(1), eq::<i32, _>(2)).describe(MatcherResult::Match),
204204
displays_as(eq(indoc!(
205205
"
206206
is a tuple whose values respectively match:
@@ -213,7 +213,7 @@ fn tuple_matcher_2_has_correct_description_for_match() -> Result<()> {
213213
#[test]
214214
fn tuple_matcher_2_has_correct_description_for_mismatch() -> Result<()> {
215215
verify_that!(
216-
(eq(1), eq(2)).describe(MatcherResult::NoMatch),
216+
(eq::<i32, _>(1), eq::<i32, _>(2)).describe(MatcherResult::NoMatch),
217217
displays_as(eq(indoc!(
218218
"
219219
is a tuple whose values do not respectively match:

googletest/tests/unordered_elements_are_matcher_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ fn is_contained_in_matches_hash_map_with_trailing_comma() -> Result<()> {
352352

353353
#[test]
354354
fn is_contained_in_matches_when_container_is_empty() -> Result<()> {
355-
verify_that!(vec![], is_contained_in!(eq(2), eq(3), eq(4)))
355+
verify_that!(vec![], is_contained_in!(eq::<i32, _>(2), eq(3), eq(4)))
356356
}
357357

358358
#[test]

0 commit comments

Comments
 (0)