Skip to content

Commit 63a2933

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 63a2933

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

+282
-294
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: 10 additions & 6 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,22 +234,26 @@ 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
}

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]

googletest/src/matchers/contains_matcher.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ where
9292
} else {
9393
for v in actual.into_iter() {
9494
if self.inner.matches(v).into() {
95-
return MatcherResult::Matches;
95+
return MatcherResult::Match;
9696
}
9797
}
98-
MatcherResult::DoesNotMatch
98+
MatcherResult::NoMatch
9999
}
100100
}
101101

@@ -110,22 +110,22 @@ where
110110

111111
fn describe(&self, matcher_result: MatcherResult) -> String {
112112
match (matcher_result, &self.count) {
113-
(MatcherResult::Matches, Some(count)) => format!(
113+
(MatcherResult::Match, Some(count)) => format!(
114114
"contains n elements which {}\n where n {}",
115-
self.inner.describe(MatcherResult::Matches),
116-
count.describe(MatcherResult::Matches)
115+
self.inner.describe(MatcherResult::Match),
116+
count.describe(MatcherResult::Match)
117117
),
118-
(MatcherResult::DoesNotMatch, Some(count)) => format!(
118+
(MatcherResult::NoMatch, Some(count)) => format!(
119119
"doesn't contain n elements which {}\n where n {}",
120-
self.inner.describe(MatcherResult::Matches),
121-
count.describe(MatcherResult::Matches)
120+
self.inner.describe(MatcherResult::Match),
121+
count.describe(MatcherResult::Match)
122122
),
123-
(MatcherResult::Matches, None) => format!(
123+
(MatcherResult::Match, None) => format!(
124124
"contains at least one element which {}",
125-
self.inner.describe(MatcherResult::Matches)
125+
self.inner.describe(MatcherResult::Match)
126126
),
127-
(MatcherResult::DoesNotMatch, None) => {
128-
format!("contains no element which {}", self.inner.describe(MatcherResult::Matches))
127+
(MatcherResult::NoMatch, None) => {
128+
format!("contains no element which {}", self.inner.describe(MatcherResult::Match))
129129
}
130130
}
131131
}
@@ -159,7 +159,7 @@ mod tests {
159159

160160
let result = matcher.matches(&vec![1]);
161161

162-
verify_that!(result, eq(MatcherResult::Matches))
162+
verify_that!(result, eq(MatcherResult::Match))
163163
}
164164

165165
#[test]
@@ -168,7 +168,7 @@ mod tests {
168168

169169
let result = matcher.matches(&vec![1]);
170170

171-
verify_that!(result, eq(MatcherResult::Matches))
171+
verify_that!(result, eq(MatcherResult::Match))
172172
}
173173

174174
#[test]
@@ -177,7 +177,7 @@ mod tests {
177177

178178
let result = matcher.matches(&[0, 1]);
179179

180-
verify_that!(result, eq(MatcherResult::Matches))
180+
verify_that!(result, eq(MatcherResult::Match))
181181
}
182182

183183
#[test]
@@ -186,7 +186,7 @@ mod tests {
186186

187187
let result = matcher.matches(&[0]);
188188

189-
verify_that!(result, eq(MatcherResult::DoesNotMatch))
189+
verify_that!(result, eq(MatcherResult::NoMatch))
190190
}
191191

192192
#[test]
@@ -195,7 +195,7 @@ mod tests {
195195

196196
let result = matcher.matches(&[]);
197197

198-
verify_that!(result, eq(MatcherResult::DoesNotMatch))
198+
verify_that!(result, eq(MatcherResult::NoMatch))
199199
}
200200

201201
#[test]
@@ -204,7 +204,7 @@ mod tests {
204204

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

207-
verify_that!(result, eq(MatcherResult::Matches))
207+
verify_that!(result, eq(MatcherResult::Match))
208208
}
209209

210210
#[test]
@@ -213,7 +213,7 @@ mod tests {
213213

214214
let result = matcher.matches(&[0, 1]);
215215

216-
verify_that!(result, eq(MatcherResult::DoesNotMatch))
216+
verify_that!(result, eq(MatcherResult::NoMatch))
217217
}
218218

219219
#[test]
@@ -222,15 +222,15 @@ mod tests {
222222

223223
let result = matcher.matches(&[1, 1]);
224224

225-
verify_that!(result, eq(MatcherResult::DoesNotMatch))
225+
verify_that!(result, eq(MatcherResult::NoMatch))
226226
}
227227

228228
#[test]
229229
fn contains_formats_without_multiplicity_by_default() -> Result<()> {
230230
let matcher: ContainsMatcher<Vec<i32>, _> = contains(eq(1));
231231

232232
verify_that!(
233-
Matcher::describe(&matcher, MatcherResult::Matches),
233+
Matcher::describe(&matcher, MatcherResult::Match),
234234
eq("contains at least one element which is equal to 1")
235235
)
236236
}
@@ -240,7 +240,7 @@ mod tests {
240240
let matcher: ContainsMatcher<Vec<i32>, _> = contains(eq(1)).times(eq(2));
241241

242242
verify_that!(
243-
Matcher::describe(&matcher, MatcherResult::Matches),
243+
Matcher::describe(&matcher, MatcherResult::Match),
244244
eq("contains n elements which is equal to 1\n where n is equal to 2")
245245
)
246246
}

0 commit comments

Comments
 (0)