Skip to content

Commit 20d035d

Browse files
bjacotgcopybara-github
authored andcommitted
Reformat googletest completely with new rustfmt
PiperOrigin-RevId: 690542867
1 parent b623956 commit 20d035d

File tree

10 files changed

+77
-60
lines changed

10 files changed

+77
-60
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,22 @@ jobs:
7171
toolchain: ${{ matrix.toolchain }}
7272
- name: cargo test --locked
7373
run: cargo test --locked --all-features
74-
# TODO: b/371562818 - Reenable linter CI.
74+
75+
lint:
76+
runs-on: ubuntu-latest
77+
name: lint / ubuntu
78+
strategy:
79+
matrix:
80+
toolchain: [nightly]
81+
steps:
82+
- uses: actions/checkout@v4
83+
- name: Install ${{ matrix.toolchain }}
84+
uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17
85+
with:
86+
toolchain: ${{ matrix.toolchain }}
87+
components: rustfmt
88+
- name: cargo fmt --check
89+
run: cargo fmt --check
7590

7691
test-no-default-features:
7792
runs-on: ubuntu-latest

googletest/src/matcher.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,11 @@ pub enum MatcherResult {
263263

264264
impl From<bool> for MatcherResult {
265265
fn from(b: bool) -> Self {
266-
if b { MatcherResult::Match } else { MatcherResult::NoMatch }
266+
if b {
267+
MatcherResult::Match
268+
} else {
269+
MatcherResult::NoMatch
270+
}
267271
}
268272
}
269273

googletest/src/matcher_support/edit_distance.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@ mod tests {
430430
}
431431

432432
#[test]
433-
fn returns_common_part_plus_difference_plus_common_part_when_there_is_common_prefix_and_suffix()
434-
-> Result<()> {
433+
fn returns_common_part_plus_difference_plus_common_part_when_there_is_common_prefix_and_suffix(
434+
) -> Result<()> {
435435
let result = edit_list(
436436
["Common part (1)", "Actual only", "Common part (2)"],
437437
["Common part (1)", "Expected only", "Common part (2)"],
@@ -449,8 +449,8 @@ mod tests {
449449
}
450450

451451
#[test]
452-
fn returns_common_part_plus_extra_actual_plus_common_part_when_there_is_common_prefix_and_suffix()
453-
-> Result<()> {
452+
fn returns_common_part_plus_extra_actual_plus_common_part_when_there_is_common_prefix_and_suffix(
453+
) -> Result<()> {
454454
let result = edit_list(
455455
["Common part (1)", "Actual only", "Common part (2)"],
456456
["Common part (1)", "Common part (2)"],
@@ -467,8 +467,8 @@ mod tests {
467467
}
468468

469469
#[test]
470-
fn returns_common_part_plus_extra_expected_plus_common_part_when_there_is_common_prefix_and_suffix()
471-
-> Result<()> {
470+
fn returns_common_part_plus_extra_expected_plus_common_part_when_there_is_common_prefix_and_suffix(
471+
) -> Result<()> {
472472
let result = edit_list(
473473
["Common part (1)", "Common part (2)"],
474474
["Common part (1)", "Expected only", "Common part (2)"],
@@ -500,8 +500,8 @@ mod tests {
500500
}
501501

502502
#[test]
503-
fn does_not_skip_extra_parts_on_actual_in_prefix_mode_at_end_when_they_are_in_common()
504-
-> Result<()> {
503+
fn does_not_skip_extra_parts_on_actual_in_prefix_mode_at_end_when_they_are_in_common(
504+
) -> Result<()> {
505505
let result = edit_list(
506506
["Actual only", "Common part"],
507507
["Expected only", "Common part"],
@@ -518,8 +518,8 @@ mod tests {
518518
}
519519

520520
#[test]
521-
fn does_not_skip_corresponding_line_on_actual_when_actual_and_expected_differ_in_prefix_mode()
522-
-> Result<()> {
521+
fn does_not_skip_corresponding_line_on_actual_when_actual_and_expected_differ_in_prefix_mode(
522+
) -> Result<()> {
523523
let result = edit_list(["Actual only"], ["Expected only"], Mode::Prefix);
524524
verify_that!(
525525
result,

googletest/src/matchers/container_eq_matcher.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,15 @@ mod tests {
240240
}
241241

242242
#[test]
243-
fn container_eq_matches_owned_vec_of_owned_strings_with_slice_of_string_references()
244-
-> Result<()> {
243+
fn container_eq_matches_owned_vec_of_owned_strings_with_slice_of_string_references(
244+
) -> Result<()> {
245245
let vector = vec!["A string".to_string(), "Another string".to_string()];
246246
verify_that!(vector, container_eq(["A string", "Another string"]))
247247
}
248248

249249
#[test]
250-
fn container_eq_matches_owned_vec_of_owned_strings_with_shorter_slice_of_string_references()
251-
-> Result<()> {
250+
fn container_eq_matches_owned_vec_of_owned_strings_with_shorter_slice_of_string_references(
251+
) -> Result<()> {
252252
let actual = vec!["A string".to_string(), "Another string".to_string()];
253253
let matcher = container_eq(["A string"]);
254254

googletest/src/matchers/property_matcher.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,11 @@ pub mod internal {
317317
}
318318

319319
impl<
320-
InnerT: Debug,
321-
OuterT: Debug + Copy,
322-
MatcherT: for<'a> Matcher<&'a InnerT>,
323-
ExtractorT: Fn(OuterT) -> InnerT,
324-
> Matcher<OuterT> for PropertyRefMatcher<ExtractorT, MatcherT>
320+
InnerT: Debug,
321+
OuterT: Debug + Copy,
322+
MatcherT: for<'a> Matcher<&'a InnerT>,
323+
ExtractorT: Fn(OuterT) -> InnerT,
324+
> Matcher<OuterT> for PropertyRefMatcher<ExtractorT, MatcherT>
325325
{
326326
fn matches(&self, actual: OuterT) -> MatcherResult {
327327
self.inner.matches(&(self.extractor)(actual))

googletest/src/matchers/str_matcher.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,8 @@ mod tests {
699699
}
700700

701701
#[test]
702-
fn matches_string_containing_expected_value_in_contains_mode_while_ignoring_ascii_case()
703-
-> Result<()> {
702+
fn matches_string_containing_expected_value_in_contains_mode_while_ignoring_ascii_case(
703+
) -> Result<()> {
704704
verify_that!("Some string", contains_substring("STR").ignoring_ascii_case())
705705
}
706706

@@ -844,8 +844,8 @@ mod tests {
844844
}
845845

846846
#[test]
847-
fn describes_itself_for_matching_result_ignoring_ascii_case_and_leading_whitespace()
848-
-> Result<()> {
847+
fn describes_itself_for_matching_result_ignoring_ascii_case_and_leading_whitespace(
848+
) -> Result<()> {
849849
let matcher = StrMatcher::with_default_config("A string")
850850
.ignoring_leading_whitespace()
851851
.ignoring_ascii_case();
@@ -985,8 +985,8 @@ mod tests {
985985
}
986986

987987
#[test]
988-
fn match_explanation_for_starts_with_includes_both_versions_of_differing_last_line()
989-
-> Result<()> {
988+
fn match_explanation_for_starts_with_includes_both_versions_of_differing_last_line(
989+
) -> Result<()> {
990990
let result = verify_that!(
991991
indoc!(
992992
"
@@ -1087,8 +1087,8 @@ mod tests {
10871087
}
10881088

10891089
#[test]
1090-
fn match_explanation_for_contains_substring_shows_diff_when_first_and_last_line_are_incomplete()
1091-
-> Result<()> {
1090+
fn match_explanation_for_contains_substring_shows_diff_when_first_and_last_line_are_incomplete(
1091+
) -> Result<()> {
10921092
let result = verify_that!(
10931093
indoc!(
10941094
"

googletest/src/matchers/unordered_elements_are_matcher.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -860,9 +860,9 @@ mod tests {
860860
// aren't dropped too early.
861861
let matchers = ((eq(&2), eq(&"Two")), (eq(&1), eq(&"One")), (eq(&3), eq(&"Three")));
862862
let matcher = unordered_elements_are![
863-
(matchers.0.0, matchers.0.1),
864-
(matchers.1.0, matchers.1.1),
865-
(matchers.2.0, matchers.2.1)
863+
(matchers.0 .0, matchers.0 .1),
864+
(matchers.1 .0, matchers.1 .1),
865+
(matchers.2 .0, matchers.2 .1)
866866
];
867867
verify_that!(
868868
Matcher::<&HashMap<i32, String>>::describe(&matcher, MatcherResult::Match),
@@ -892,9 +892,9 @@ mod tests {
892892
let value: HashMap<u32, u32> = HashMap::from_iter([(0, 1), (1, 1), (2, 2)]);
893893
let matchers = ((anything(), eq(&1)), (anything(), eq(&2)), (anything(), eq(&2)));
894894
let matcher = unordered_elements_are![
895-
(matchers.0.0, matchers.0.1),
896-
(matchers.1.0, matchers.1.1),
897-
(matchers.2.0, matchers.2.1),
895+
(matchers.0 .0, matchers.0 .1),
896+
(matchers.1 .0, matchers.1 .1),
897+
(matchers.2 .0, matchers.2 .1),
898898
];
899899
verify_that!(
900900
matcher.explain_match(&value),

googletest/tests/matches_pattern_test.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,8 +1103,8 @@ fn matches_struct_with_a_method_returning_reference_followed_by_a_field() -> Res
11031103
)
11041104
}
11051105
#[test]
1106-
fn matches_struct_with_a_method_returning_reference_followed_by_a_field_with_trailing_comma()
1107-
-> Result<()> {
1106+
fn matches_struct_with_a_method_returning_reference_followed_by_a_field_with_trailing_comma(
1107+
) -> Result<()> {
11081108
#[derive(Debug)]
11091109
struct AStruct {
11101110
a_field: u32,
@@ -1171,8 +1171,8 @@ fn matches_struct_with_a_method_taking_enum_value_param_ret_ref_followed_by_fiel
11711171
)
11721172
}
11731173
#[test]
1174-
fn matches_struct_with_a_method_taking_two_parameters_with_trailing_comma_ret_ref_and_field()
1175-
-> Result<()> {
1174+
fn matches_struct_with_a_method_taking_two_parameters_with_trailing_comma_ret_ref_and_field(
1175+
) -> Result<()> {
11761176
#[derive(Debug)]
11771177
struct AStruct {
11781178
a_field: u32,
@@ -1391,8 +1391,8 @@ fn matches_struct_with_field_followed_by_method_taking_enum_value_param_ret_ref(
13911391
)
13921392
}
13931393
#[test]
1394-
fn matches_struct_with_a_field_followed_by_a_method_with_params_and_trailing_comma_ret_ref()
1395-
-> Result<()> {
1394+
fn matches_struct_with_a_field_followed_by_a_method_with_params_and_trailing_comma_ret_ref(
1395+
) -> Result<()> {
13961396
#[derive(Debug)]
13971397
struct AStruct {
13981398
a_field: u32,
@@ -1439,8 +1439,8 @@ fn matches_struct_with_a_field_followed_by_a_method_followed_by_a_field() -> Res
14391439
)
14401440
}
14411441
#[test]
1442-
fn matches_struct_with_a_field_followed_by_a_method_followed_by_a_field_with_trailing_comma()
1443-
-> Result<()> {
1442+
fn matches_struct_with_a_field_followed_by_a_method_followed_by_a_field_with_trailing_comma(
1443+
) -> Result<()> {
14441444
#[derive(Debug)]
14451445
struct AStruct {
14461446
a_field: u32,
@@ -1494,8 +1494,8 @@ fn matches_struct_with_a_field_followed_by_a_method_with_params_followed_by_a_fi
14941494
}
14951495

14961496
#[test]
1497-
fn matches_struct_with_a_field_followed_by_a_method_with_params_and_trailing_comma_followed_by_a_field()
1498-
-> Result<()> {
1497+
fn matches_struct_with_a_field_followed_by_a_method_with_params_and_trailing_comma_followed_by_a_field(
1498+
) -> Result<()> {
14991499
#[derive(Debug)]
15001500
struct AStruct {
15011501
a_field: u32,
@@ -1522,8 +1522,8 @@ fn matches_struct_with_a_field_followed_by_a_method_with_params_and_trailing_com
15221522
}
15231523

15241524
#[test]
1525-
fn matches_struct_with_field_followed_by_method_taking_enum_value_param_followed_by_field()
1526-
-> Result<()> {
1525+
fn matches_struct_with_field_followed_by_method_taking_enum_value_param_followed_by_field(
1526+
) -> Result<()> {
15271527
enum AnEnum {
15281528
AVariant,
15291529
}
@@ -1581,8 +1581,8 @@ fn matches_struct_with_a_field_followed_by_a_method_ret_ref_followed_by_a_field(
15811581
}
15821582

15831583
#[test]
1584-
fn matches_struct_with_a_field_followed_by_a_method_ret_ref_followed_by_a_field_with_trailing_comma()
1585-
-> Result<()> {
1584+
fn matches_struct_with_a_field_followed_by_a_method_ret_ref_followed_by_a_field_with_trailing_comma(
1585+
) -> Result<()> {
15861586
#[derive(Debug)]
15871587
struct AStruct {
15881588
a_field: u32,
@@ -1609,8 +1609,8 @@ fn matches_struct_with_a_field_followed_by_a_method_ret_ref_followed_by_a_field_
16091609
}
16101610

16111611
#[test]
1612-
fn matches_struct_with_a_field_followed_by_a_method_with_params_ret_ref_followed_by_a_field()
1613-
-> Result<()> {
1612+
fn matches_struct_with_a_field_followed_by_a_method_with_params_ret_ref_followed_by_a_field(
1613+
) -> Result<()> {
16141614
#[derive(Debug)]
16151615
struct AStruct {
16161616
a_field: u32,
@@ -1637,8 +1637,8 @@ fn matches_struct_with_a_field_followed_by_a_method_with_params_ret_ref_followed
16371637
}
16381638

16391639
#[test]
1640-
fn matches_struct_with_field_followed_by_method_taking_enum_value_param_ret_ref_followed_by_field()
1641-
-> Result<()> {
1640+
fn matches_struct_with_field_followed_by_method_taking_enum_value_param_ret_ref_followed_by_field(
1641+
) -> Result<()> {
16421642
enum AnEnum {
16431643
AVariant,
16441644
}
@@ -1669,8 +1669,8 @@ fn matches_struct_with_field_followed_by_method_taking_enum_value_param_ret_ref_
16691669
}
16701670

16711671
#[test]
1672-
fn matches_struct_with_a_field_followed_by_a_method_with_params_trailing_comma_ret_ref_followed_by_a_field()
1673-
-> Result<()> {
1672+
fn matches_struct_with_a_field_followed_by_a_method_with_params_trailing_comma_ret_ref_followed_by_a_field(
1673+
) -> Result<()> {
16741674
#[derive(Debug)]
16751675
struct AStruct {
16761676
a_field: u32,

googletest/tests/pointwise_matcher_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ fn pointwise_returns_mismatch_when_actual_value_does_not_match_on_second_item()
147147
}
148148

149149
#[test]
150-
fn pointwise_returns_mismatch_when_actual_value_does_not_match_on_first_and_second_items()
151-
-> Result<()> {
150+
fn pointwise_returns_mismatch_when_actual_value_does_not_match_on_first_and_second_items(
151+
) -> Result<()> {
152152
let result = verify_that!(vec![1, 2, 3], pointwise!(eq, &vec![2, 3, 3]));
153153

154154
verify_that!(

rustfmt.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414

1515
edition = "2021"
1616

17-
# Because of this, one must use the *nightly* version of rustfmt, e.g.
18-
# cargo +nightly fmt
19-
version = "Two"
17+
style_edition = "2021"
2018

2119
use_small_heuristics = "Max"
2220

0 commit comments

Comments
 (0)