Skip to content

Commit 14b2d2a

Browse files
hovinenbcopybara-github
authored andcommitted
Modify the description and match explanation of the len matcher to use the word length rather than size.
The word `length` is more idiomatic Rust and reduces the risk of confusion with byte size. PiperOrigin-RevId: 545187859
1 parent e8eebff commit 14b2d2a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

googletest/src/matchers/len_matcher.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,17 @@ where
7171
fn describe(&self, matcher_result: MatcherResult) -> String {
7272
match matcher_result {
7373
MatcherResult::Matches => {
74-
format!("has size, which {}", self.expected.describe(MatcherResult::Matches))
74+
format!("has length, which {}", self.expected.describe(MatcherResult::Matches))
7575
}
7676
MatcherResult::DoesNotMatch => {
77-
format!("has size, which {}", self.expected.describe(MatcherResult::DoesNotMatch))
77+
format!("has length, which {}", self.expected.describe(MatcherResult::DoesNotMatch))
7878
}
7979
}
8080
}
8181

8282
fn explain_match(&self, actual: &T) -> String {
8383
let actual_size = count_elements(actual);
84-
format!("which has size {}, {}", actual_size, self.expected.explain_match(&actual_size))
84+
format!("which has length {}, {}", actual_size, self.expected.explain_match(&actual_size))
8585
}
8686
}
8787

@@ -190,7 +190,7 @@ mod tests {
190190
}
191191
verify_that!(
192192
len(TestMatcher(Default::default())).explain_match(&[1, 2, 3]),
193-
displays_as(eq("which has size 3, called explain_match"))
193+
displays_as(eq("which has length 3, called explain_match"))
194194
)
195195
}
196196

@@ -202,9 +202,9 @@ mod tests {
202202
err(displays_as(contains_substring(indoc!(
203203
"
204204
Value of: vec![1, 2, 3, 4]
205-
Expected: has size, which is equal to 3
205+
Expected: has length, which is equal to 3
206206
Actual: [1, 2, 3, 4],
207-
which has size 4, which isn't equal to 3"
207+
which has length 4, which isn't equal to 3"
208208
))))
209209
)
210210
}

0 commit comments

Comments
 (0)