Skip to content

Commit 4e81bc2

Browse files
committed
Rename the enum variants of MatcherResult to Match and NoMatch.
These new names are more concise and better correspond to the naming of `MatcherResult`. Namely, they are nouns specifying the result rather than verbs.
1 parent a7de523 commit 4e81bc2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+283
-295
lines changed

googletest/crate_docs.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,18 @@ impl<T: PartialEq + Debug> Matcher for MyEqMatcher<T> {
179179
180180
fn matches(&self, actual: &Self::ActualT) -> MatcherResult {
181181
if self.expected == *actual {
182-
MatcherResult::Matches
182+
MatcherResult::Match
183183
} else {
184-
MatcherResult::DoesNotMatch
184+
MatcherResult::NoMatch
185185
}
186186
}
187187
188188
fn describe(&self, matcher_result: MatcherResult) -> String {
189189
match matcher_result {
190-
MatcherResult::Matches => {
190+
MatcherResult::Match => {
191191
format!("is equal to {:?} the way I define it", self.expected)
192192
}
193-
MatcherResult::DoesNotMatch => {
193+
MatcherResult::NoMatch => {
194194
format!("isn't equal to {:?} the way I define it", self.expected)
195195
}
196196
}
@@ -213,18 +213,18 @@ impl<T: PartialEq + Debug> Matcher for MyEqMatcher<T> {
213213
#
214214
# fn matches(&self, actual: &Self::ActualT) -> MatcherResult {
215215
# if self.expected == *actual {
216-
# MatcherResult::Matches
216+
# MatcherResult::Match
217217
# } else {
218-
# MatcherResult::DoesNotMatch
218+
# MatcherResult::NoMatch
219219
# }
220220
# }
221221
#
222222
# fn describe(&self, matcher_result: MatcherResult) -> String {
223223
# match matcher_result {
224-
# MatcherResult::Matches => {
224+
# MatcherResult::Match => {
225225
# format!("is equal to {:?} the way I define it", self.expected)
226226
# }
227-
# MatcherResult::DoesNotMatch => {
227+
# MatcherResult::NoMatch => {
228228
# format!("isn't equal to {:?} the way I define it", self.expected)
229229
# }
230230
# }
@@ -252,18 +252,18 @@ impl<T: PartialEq + Debug> Matcher for MyEqMatcher<T> {
252252
#
253253
# fn matches(&self, actual: &Self::ActualT) -> MatcherResult {
254254
# if self.expected == *actual {
255-
# MatcherResult::Matches
255+
# MatcherResult::Match
256256
# } else {
257-
# MatcherResult::DoesNotMatch
257+
# MatcherResult::NoMatch
258258
# }
259259
# }
260260
#
261261
# fn describe(&self, matcher_result: MatcherResult) -> String {
262262
# match matcher_result {
263-
# MatcherResult::Matches => {
263+
# MatcherResult::Match => {
264264
# format!("is equal to {:?} the way I define it", self.expected)
265265
# }
266-
# MatcherResult::DoesNotMatch => {
266+
# MatcherResult::NoMatch => {
267267
# format!("isn't equal to {:?} the way I define it", self.expected)
268268
# }
269269
# }

googletest/src/assertions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ pub mod internal {
355355
source_location: SourceLocation,
356356
) -> Result<(), TestAssertionFailure> {
357357
match expected.matches(actual) {
358-
MatcherResult::Matches => Ok(()),
359-
MatcherResult::DoesNotMatch => {
358+
MatcherResult::Match => Ok(()),
359+
MatcherResult::NoMatch => {
360360
Err(create_assertion_failure(&expected, actual, actual_expr, source_location))
361361
}
362362
}

googletest/src/matcher.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ Expected: {}
225225
Actual: {actual_formatted},
226226
{}
227227
{source_location}",
228-
matcher.describe(MatcherResult::Matches),
228+
matcher.describe(MatcherResult::Match),
229229
matcher.explain_match(actual),
230230
))
231231
}
@@ -234,28 +234,32 @@ Actual: {actual_formatted},
234234
#[derive(Debug, PartialEq, Clone, Copy)]
235235
pub enum MatcherResult {
236236
/// The actual value matches according to the [`Matcher`] definition.
237-
Matches,
237+
Match,
238238
/// The actual value does not match according to the [`Matcher`] definition.
239-
DoesNotMatch,
239+
NoMatch,
240240
}
241241

242242
impl From<bool> for MatcherResult {
243243
fn from(b: bool) -> Self {
244-
if b { MatcherResult::Matches } else { MatcherResult::DoesNotMatch }
244+
if b {
245+
MatcherResult::Match
246+
} else {
247+
MatcherResult::NoMatch
248+
}
245249
}
246250
}
247251

248252
impl From<MatcherResult> for bool {
249253
fn from(matcher_result: MatcherResult) -> Self {
250254
match matcher_result {
251-
MatcherResult::Matches => true,
252-
MatcherResult::DoesNotMatch => false,
255+
MatcherResult::Match => true,
256+
MatcherResult::NoMatch => false,
253257
}
254258
}
255259
}
256260

257261
impl MatcherResult {
258-
/// Returns `true` if `self` is [`MatcherResult::Matches`], otherwise
262+
/// Returns `true` if `self` is [`MatcherResult::Match`], otherwise
259263
/// `false`.
260264
///
261265
/// This delegates to `Into<bool>` but coerce the return type to `bool`

googletest/src/matchers/all_matcher.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ pub mod internal {
9292
fn matches(&self, actual: &Self::ActualT) -> MatcherResult {
9393
for component in &self.components {
9494
match component.matches(actual) {
95-
MatcherResult::DoesNotMatch => {
96-
return MatcherResult::DoesNotMatch;
95+
MatcherResult::NoMatch => {
96+
return MatcherResult::NoMatch;
9797
}
98-
MatcherResult::Matches => {}
98+
MatcherResult::Match => {}
9999
}
100100
}
101-
MatcherResult::Matches
101+
MatcherResult::Match
102102
}
103103

104104
fn explain_match(&self, actual: &Self::ActualT) -> String {
@@ -161,7 +161,7 @@ mod tests {
161161
let matcher: internal::AllMatcher<String, 2> = all!(first_matcher, second_matcher);
162162

163163
verify_that!(
164-
matcher.describe(MatcherResult::Matches),
164+
matcher.describe(MatcherResult::Match),
165165
eq(indoc!(
166166
"
167167
has all the following properties:
@@ -176,7 +176,7 @@ mod tests {
176176
let first_matcher = starts_with("A");
177177
let matcher: internal::AllMatcher<String, 1> = all!(first_matcher);
178178

179-
verify_that!(matcher.describe(MatcherResult::Matches), eq("starts with prefix \"A\""))
179+
verify_that!(matcher.describe(MatcherResult::Match), eq("starts with prefix \"A\""))
180180
}
181181

182182
#[test]

googletest/src/matchers/anything_matcher.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ impl<T: Debug + ?Sized> Matcher for Anything<T> {
3939
type ActualT = T;
4040

4141
fn matches(&self, _: &T) -> MatcherResult {
42-
MatcherResult::Matches
42+
MatcherResult::Match
4343
}
4444

4545
fn describe(&self, matcher_result: MatcherResult) -> String {
4646
match matcher_result {
47-
MatcherResult::Matches => "is anything".to_string(),
48-
MatcherResult::DoesNotMatch => "never matches".to_string(),
47+
MatcherResult::Match => "is anything".to_string(),
48+
MatcherResult::NoMatch => "never matches".to_string(),
4949
}
5050
}
5151
}

googletest/src/matchers/char_count_matcher.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ impl<T: Debug + ?Sized + AsRef<str>, E: Matcher<ActualT = usize>> Matcher for Ch
7373

7474
fn describe(&self, matcher_result: MatcherResult) -> String {
7575
match matcher_result {
76-
MatcherResult::Matches => {
76+
MatcherResult::Match => {
7777
format!(
7878
"has character count, which {}",
79-
self.expected.describe(MatcherResult::Matches)
79+
self.expected.describe(MatcherResult::Match)
8080
)
8181
}
82-
MatcherResult::DoesNotMatch => {
82+
MatcherResult::NoMatch => {
8383
format!(
8484
"has character count, which {}",
85-
self.expected.describe(MatcherResult::DoesNotMatch)
85+
self.expected.describe(MatcherResult::NoMatch)
8686
)
8787
}
8888
}

googletest/src/matchers/conjunction_matcher.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,23 @@ where
3838

3939
fn matches(&self, actual: &M1::ActualT) -> MatcherResult {
4040
match (self.m1.matches(actual), self.m2.matches(actual)) {
41-
(MatcherResult::Matches, MatcherResult::Matches) => MatcherResult::Matches,
42-
_ => MatcherResult::DoesNotMatch,
41+
(MatcherResult::Match, MatcherResult::Match) => MatcherResult::Match,
42+
_ => MatcherResult::NoMatch,
4343
}
4444
}
4545

4646
fn explain_match(&self, actual: &M1::ActualT) -> String {
4747
match (self.m1.matches(actual), self.m2.matches(actual)) {
48-
(MatcherResult::Matches, MatcherResult::Matches) => {
48+
(MatcherResult::Match, MatcherResult::Match) => {
4949
format!(
5050
"{} and\n {}",
5151
self.m1.explain_match(actual),
5252
self.m2.explain_match(actual)
5353
)
5454
}
55-
(MatcherResult::DoesNotMatch, MatcherResult::Matches) => self.m1.explain_match(actual),
56-
(MatcherResult::Matches, MatcherResult::DoesNotMatch) => self.m2.explain_match(actual),
57-
(MatcherResult::DoesNotMatch, MatcherResult::DoesNotMatch) => {
55+
(MatcherResult::NoMatch, MatcherResult::Match) => self.m1.explain_match(actual),
56+
(MatcherResult::Match, MatcherResult::NoMatch) => self.m2.explain_match(actual),
57+
(MatcherResult::NoMatch, MatcherResult::NoMatch) => {
5858
format!(
5959
"{} and\n {}",
6060
self.m1.explain_match(actual),

googletest/src/matchers/container_eq_matcher.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ where
120120

121121
fn describe(&self, matcher_result: MatcherResult) -> String {
122122
match matcher_result {
123-
MatcherResult::Matches => format!("is equal to {:?}", self.expected),
124-
MatcherResult::DoesNotMatch => format!("isn't equal to {:?}", self.expected),
123+
MatcherResult::Match => format!("is equal to {:?}", self.expected),
124+
MatcherResult::NoMatch => format!("isn't equal to {:?}", self.expected),
125125
}
126126
}
127127
}
@@ -265,21 +265,21 @@ mod tests {
265265
}
266266

267267
#[test]
268-
fn container_eq_matches_owned_vec_of_owned_strings_with_slice_of_string_references()
269-
-> Result<()> {
268+
fn container_eq_matches_owned_vec_of_owned_strings_with_slice_of_string_references(
269+
) -> Result<()> {
270270
let vector = vec!["A string".to_string(), "Another string".to_string()];
271271
verify_that!(vector, container_eq(["A string", "Another string"]))
272272
}
273273

274274
#[test]
275-
fn container_eq_matches_owned_vec_of_owned_strings_with_shorter_slice_of_string_references()
276-
-> Result<()> {
275+
fn container_eq_matches_owned_vec_of_owned_strings_with_shorter_slice_of_string_references(
276+
) -> Result<()> {
277277
let actual = vec!["A string".to_string(), "Another string".to_string()];
278278
let matcher = container_eq(["A string"]);
279279

280280
let result = matcher.matches(&actual);
281281

282-
verify_that!(result, eq(MatcherResult::DoesNotMatch))
282+
verify_that!(result, eq(MatcherResult::NoMatch))
283283
}
284284

285285
#[test]

0 commit comments

Comments
 (0)