mirror of
https://github.com/google/googletest.git
synced 2025-12-21 02:54:55 +08:00
Merge branch 'google:main' into master
This commit is contained in:
commit
6f59c1f1d2
@ -1084,7 +1084,7 @@ using ::testing::Lt;
|
|||||||
```
|
```
|
||||||
|
|
||||||
says that `Blah` will be called with arguments `x`, `y`, and `z` where `x < y <
|
says that `Blah` will be called with arguments `x`, `y`, and `z` where `x < y <
|
||||||
z`. Note that in this example, it wasn't necessary specify the positional
|
z`. Note that in this example, it wasn't necessary to specify the positional
|
||||||
matchers.
|
matchers.
|
||||||
|
|
||||||
As a convenience and example, gMock provides some matchers for 2-tuples,
|
As a convenience and example, gMock provides some matchers for 2-tuples,
|
||||||
|
|||||||
@ -76,6 +76,13 @@ template <typename Pointer>
|
|||||||
inline const typename Pointer::element_type* GetRawPointer(const Pointer& p) {
|
inline const typename Pointer::element_type* GetRawPointer(const Pointer& p) {
|
||||||
return p.get();
|
return p.get();
|
||||||
}
|
}
|
||||||
|
// This overload version is for std::reference_wrapper, which does not work with
|
||||||
|
// the overload above, as it does not have an `element_type`.
|
||||||
|
template <typename Element>
|
||||||
|
inline const Element* GetRawPointer(const std::reference_wrapper<Element>& r) {
|
||||||
|
return &r.get();
|
||||||
|
}
|
||||||
|
|
||||||
// This overloaded version is for the raw pointer case.
|
// This overloaded version is for the raw pointer case.
|
||||||
template <typename Element>
|
template <typename Element>
|
||||||
inline Element* GetRawPointer(Element* p) { return p; }
|
inline Element* GetRawPointer(Element* p) { return p; }
|
||||||
|
|||||||
@ -140,6 +140,12 @@ TEST(GetRawPointerTest, WorksForRawPointers) {
|
|||||||
EXPECT_EQ(&n, GetRawPointer(&n));
|
EXPECT_EQ(&n, GetRawPointer(&n));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(GetRawPointerTest, WorksForStdReferenceWrapper) {
|
||||||
|
int n = 1;
|
||||||
|
EXPECT_EQ(&n, GetRawPointer(std::ref(n)));
|
||||||
|
EXPECT_EQ(&n, GetRawPointer(std::cref(n)));
|
||||||
|
}
|
||||||
|
|
||||||
// Tests KindOf<T>.
|
// Tests KindOf<T>.
|
||||||
|
|
||||||
class Base {};
|
class Base {};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user