diff options
author | Abseil Team <absl-team@google.com> | 2021-02-03 02:11:55 (GMT) |
---|---|---|
committer | Dino Radaković <dinor@google.com> | 2021-02-05 18:41:02 (GMT) |
commit | b6323d216d3e5ebd183abf7b379069a17c923342 (patch) | |
tree | 257e70872ccf482e6bbf371fed65ddc481dbab8d | |
parent | aea7f60bf52e16b697fa238e90a0551643765753 (diff) | |
download | googletest-b6323d216d3e5ebd183abf7b379069a17c923342.zip googletest-b6323d216d3e5ebd183abf7b379069a17c923342.tar.gz googletest-b6323d216d3e5ebd183abf7b379069a17c923342.tar.bz2 |
Googletest export
Add a note to recommend against using `Property()` for functions that the test author does not own.
PiperOrigin-RevId: 355295183
-rw-r--r-- | docs/gmock_cheat_sheet.md | 6 | ||||
-rw-r--r-- | docs/gmock_cook_book.md | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/docs/gmock_cheat_sheet.md b/docs/gmock_cheat_sheet.md index f2b5ab1..12e4104 100644 --- a/docs/gmock_cheat_sheet.md +++ b/docs/gmock_cheat_sheet.md @@ -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. <!-- 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 <!-- mdformat off(no multiline tables) --> diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md index 26a140e..5e7cbfe 100644 --- a/docs/gmock_cook_book.md +++ b/docs/gmock_cook_book.md @@ -1216,9 +1216,11 @@ For example: <!-- mdformat on --> 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, ```cpp |