Commit b6323d21 authored by Abseil Team's avatar Abseil Team Committed by Dino Radaković
Browse files

Googletest export

Add a note to recommend against using `Property()` for functions that the test author does not own.

PiperOrigin-RevId: 355295183
parent aea7f60b
...@@ -400,6 +400,12 @@ messages, you can use: ...@@ -400,6 +400,12 @@ messages, you can use:
| `Property(property_name, &class::property, m)` | The same as the two-parameter version, but provides a better error message. | `Property(property_name, &class::property, m)` | The same as the two-parameter version, but provides a better error message.
<!-- mdformat on --> <!-- mdformat on -->
**Notes:**
* Don't use `Property()` against member functions that you do not own, because
taking addresses of functions is fragile and generally not part of the
contract of the function.
### Matching the Result of a Function, Functor, or Callback ### Matching the Result of a Function, Functor, or Callback
<!-- mdformat off(no multiline tables) --> <!-- mdformat off(no multiline tables) -->
......
...@@ -1216,9 +1216,11 @@ For example: ...@@ -1216,9 +1216,11 @@ For example:
<!-- mdformat on --> <!-- mdformat on -->
Note that in `Property(&Foo::baz, ...)`, method `baz()` must take no argument Note that in `Property(&Foo::baz, ...)`, method `baz()` must take no argument
and be declared as `const`. and be declared as `const`. Don't use `Property()` against member functions that
you do not own, because taking addresses of functions is fragile and generally
not part of the contract of the function.
BTW, `Field()` and `Property()` can also match plain pointers to objects. For `Field()` and `Property()` can also match plain pointers to objects. For
instance, instance,
```cpp ```cpp
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment