Skip to content

Commit

Permalink
Make expect_that! more hygienic
Browse files Browse the repository at this point in the history
related google#475

I went for using fully qualified method names, rather than `use $crate::GoogleTestSupport as _;` since it's more hygienic.

`use $crate::GoogleTestSupport as _;` can cause issues, resulting in a conflict, if the user introduces another method with the same name as one on `GoogleTestSupport`
  • Loading branch information
eopb committed Sep 3, 2024
1 parent 2e88080 commit 0318055
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions googletest/src/assertions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,14 +1359,16 @@ macro_rules! assert_pred {
#[macro_export]
macro_rules! expect_that {
($actual:expr, $expected:expr $(,)?) => {{
use $crate::GoogleTestSupport as _;
$crate::verify_that!($actual, $expected).and_log_failure();
$crate::GoogleTestSupport::and_log_failure($crate::verify_that!($actual, $expected));
}};

($actual:expr, $expected:expr, $($format_args:expr),* $(,)?) => {
$crate::verify_that!($actual, $expected)
.with_failure_message(|| format!($($format_args),*))
.and_log_failure()
$crate::GoogleTestSupport::and_log_failure(
$crate::GoogleTestSupport::with_failure_message(
$crate::verify_that!($actual, $expected),
|| format!($($format_args),*)
)
)
};
}

Expand Down

0 comments on commit 0318055

Please sign in to comment.