Skip to content

Commit aa39332

Browse files
hovinenbcopybara-github
authored andcommitted
Add a note to the documentation of the assert_that! and assert_pred! macros indicating the difference in behaviour between these macros and the ASSERT_THAT and ASSERT_PRED* macros in GoogleTest for C++.
Since many users of this crate are expected to start with experience in GoogleTest for C++, it's important to highlight the difference in behaviour to avoid surprises. PiperOrigin-RevId: 553770018
1 parent ba77526 commit aa39332

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

googletest/src/assertions.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,11 @@ macro_rules! fail {
307307
///
308308
/// This is analogous to assertions in most Rust test libraries, where a failed
309309
/// assertion causes a panic.
310+
///
311+
/// **Note for users of [GoogleTest for C++](http://google.github.io/googletest/):**
312+
/// This differs from the `ASSERT_THAT` macro in that it panics rather
313+
/// than triggering an early return from the invoking function. To get behaviour
314+
/// equivalent to `ASSERT_THAT`, use [`verify_that!`] with the `?` operator.
310315
#[macro_export]
311316
macro_rules! assert_that {
312317
($actual:expr, $expected:expr) => {
@@ -323,6 +328,12 @@ macro_rules! assert_that {
323328

324329
/// Asserts that the given predicate applied to the given arguments returns
325330
/// true, panicking if it does not.
331+
///
332+
/// **Note for users of [GoogleTest for C++](http://google.github.io/googletest/):**
333+
/// This differs from the `ASSERT_PRED*` family of macros in that it panics
334+
/// rather than triggering an early return from the invoking function. To get
335+
/// behaviour equivalent to `ASSERT_PRED*`, use [`verify_pred!`] with the `?`
336+
/// operator.
326337
#[macro_export]
327338
macro_rules! assert_pred {
328339
($($content:tt)*) => {

0 commit comments

Comments
 (0)