Skip to content

Commit 121e4c1

Browse files
Merge pull request #303 from google:support-trailing-comma-with-special-syntax
PiperOrigin-RevId: 564299799
2 parents 0c72697 + 7468bfe commit 121e4c1

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

googletest/src/assertions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@
120120
/// not supported; see [Rust by Example](https://doc.rust-lang.org/rust-by-example/primitives/tuples.html#tuples).
121121
#[macro_export]
122122
macro_rules! verify_that {
123-
($actual:expr, [$($expecteds:expr),+]) => {
123+
($actual:expr, [$($expecteds:expr),+ $(,)?]) => {
124124
$crate::assertions::internal::check_matcher(
125125
&$actual,
126126
$crate::elements_are![$($expecteds),+],
127127
stringify!($actual),
128128
$crate::internal::source_location::SourceLocation::new(file!(), line!(), column!()),
129129
)
130130
};
131-
($actual:expr, {$($expecteds:expr),+}) => {
131+
($actual:expr, {$($expecteds:expr),+ $(,)?}) => {
132132
$crate::assertions::internal::check_matcher(
133133
&$actual,
134134
$crate::unordered_elements_are![$($expecteds),+],

integration_tests/src/integration_tests.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ mod tests {
3636
verify_that!(vec![1, 2], {eq(2), eq(1)})
3737
}
3838

39+
#[test]
40+
fn verify_that_with_short_elements_are_syntax_supports_trailing_comma() -> Result<()> {
41+
verify_that!(vec![1, 2], [eq(1), eq(2),])
42+
}
43+
44+
#[test]
45+
fn verify_that_with_short_unordered_elements_are_syntax_supports_trailing_comma() -> Result<()>
46+
{
47+
verify_that!(vec![1, 2], {eq(2), eq(1),})
48+
}
49+
3950
#[test]
4051
fn should_pass_with_assert_that() -> Result<()> {
4152
let value = 2;

0 commit comments

Comments
 (0)