| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 300de2b commit e559ef6
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,6 +40,7 @@ | |||
| 40 | 40 | #define GOOGLETEST_INCLUDE_GTEST_GTEST_MATCHERS_H_ | |
| 41 | 41 | ||
| 42 | 42 | #include <atomic> | |
| 43 | + #include <cstddef> | ||
| 43 | 44 | #include <functional> | |
| 44 | 45 | #include <memory> | |
| 45 | 46 | #include <ostream> | |
@@ -485,6 +486,15 @@ class [[nodiscard]] Matcher : public internal::MatcherBase<T> { | |||
| 485 | 486 | // Implicit constructor here allows people to write | |
| 486 | 487 | // EXPECT_CALL(foo, Bar(5)) instead of EXPECT_CALL(foo, Bar(Eq(5))) sometimes | |
| 487 | 488 | Matcher(T value); // NOLINT | |
| 489 | + | ||
| 490 | + // Implicit constructor here allows people to write | ||
| 491 | + // EXPECT_THAT(foo, nullptr) instead of EXPECT_THAT(foo, IsNull()) for smart | ||
| 492 | + // pointer types. | ||
| 493 | + // | ||
| 494 | + // The second argument is needed to avoid capturing literal '0'. | ||
| 495 | + template <typename U> | ||
| 496 | + Matcher(U, // NOLINT | ||
| 497 | + std::enable_if_t<std::is_same_v<U, std::nullptr_t>>* = nullptr); | ||
| 488 | 498 | }; | |
| 489 | 499 | ||
| 490 | 500 | // The following two specializations allow the user to write str | |
@@ -895,13 +905,21 @@ inline internal::EqMatcher<T> Eq(T x) { | |||
| 895 | 905 | return internal::EqMatcher<T>(x); | |
| 896 | 906 | } | |
| 897 | 907 | ||
| 898 | - // Constructs a Matcher<T> from a 'value' of type T. The constructed | ||
| 908 | + // Constructs a Matcher<T> from a 'value' of type T. The constructed | ||
| 899 | 909 | // matcher matches any value that's equal to 'value'. | |
| 900 | 910 | template <typename T> | |
| 901 | 911 | Matcher<T>::Matcher(T value) { | |
| 902 | 912 | *this = Eq(value); | |
| 903 | 913 | } | |
| 904 | 914 | ||
| 915 | + // Constructs a Matcher<T> from nullptr. The constructed matcher matches any | ||
| 916 | + // value that is equal to nullptr. | ||
| 917 | + template <typename T> | ||
| 918 | + template <typename U> | ||
| 919 | + Matcher<T>::Matcher(U, std::enable_if_t<std::is_same_v<U, std::nullptr_t>>*) { | ||
| 920 | + *this = Eq(nullptr); | ||
| 921 | + } | ||
| 922 | + | ||
| 905 | 923 | // Creates a monomorphic matcher that matches anything with type Lhs | |
| 906 | 924 | // and equal to rhs. A user may need to use this instead of Eq(...) | |
| 907 | 925 | // in order to resolve an overloading ambiguity. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1452,7 +1452,7 @@ typedef GTestMutexLock MutexLock; | |||
| 1452 | 1452 | // without knowing its type. | |
| 1453 | 1453 | class [[nodiscard]] ThreadLocalValueHolderBase { | |
| 1454 | 1454 | public: | |
| 1455 | - virtual ~ThreadLocalValueHolderBase() {} | ||
| 1455 | + virtual ~ThreadLocalValueHolderBase() = default; | ||
| 1456 | 1456 | }; | |
| 1457 | 1457 | ||
| 1458 | 1458 | // Provides a way for a thread to send notifications to a ThreadLocal | |
@@ -1466,8 +1466,8 @@ class [[nodiscard]] ThreadLocalBase { | |||
| 1466 | 1466 | virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const = 0; | |
| 1467 | 1467 | ||
| 1468 | 1468 | protected: | |
| 1469 | - ThreadLocalBase() {} | ||
| 1470 | - virtual ~ThreadLocalBase() {} | ||
| 1469 | + ThreadLocalBase() = default; | ||
| 1470 | + virtual ~ThreadLocalBase() = default; | ||
| 1471 | 1471 | ||
| 1472 | 1472 | private: | |
| 1473 | 1473 | ThreadLocalBase(const ThreadLocalBase&) = delete; | |
@@ -1496,7 +1496,7 @@ class GTEST_API_ [[nodiscard]] ThreadWithParamBase { | |||
| 1496 | 1496 | protected: | |
| 1497 | 1497 | class Runnable { | |
| 1498 | 1498 | public: | |
| 1499 | - virtual ~Runnable() {} | ||
| 1499 | + virtual ~Runnable() = default; | ||
| 1500 | 1500 | virtual void Run() = 0; | |
| 1501 | 1501 | }; | |
| 1502 | 1502 | ||
@@ -1515,14 +1515,14 @@ class [[nodiscard]] ThreadWithParam : public ThreadWithParamBase { | |||
| 1515 | 1515 | ||
| 1516 | 1516 | ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start) | |
| 1517 | 1517 | : ThreadWithParamBase(new RunnableImpl(func, param), thread_can_start) {} | |
| 1518 | - virtual ~ThreadWithParam() {} | ||
| 1518 | + ~ThreadWithParam() override {} | ||
| 1519 | 1519 | ||
| 1520 | 1520 | private: | |
| 1521 | 1521 | class RunnableImpl : public Runnable { | |
| 1522 | 1522 | public: | |
| 1523 | 1523 | RunnableImpl(UserThreadFunc* func, T param) : func_(func), param_(param) {} | |
| 1524 | - virtual ~RunnableImpl() {} | ||
| 1525 | - virtual void Run() { func_(param_); } | ||
| 1524 | + ~RunnableImpl() override {} | ||
| 1525 | + void Run() override { func_(param_); } | ||
| 1526 | 1526 | ||
| 1527 | 1527 | private: | |
| 1528 | 1528 | UserThreadFunc* const func_; | |
@@ -1605,8 +1605,8 @@ class [[nodiscard]] ThreadLocal : public ThreadLocalBase { | |||
| 1605 | 1605 | ||
| 1606 | 1606 | class ValueHolderFactory { | |
| 1607 | 1607 | public: | |
| 1608 | - ValueHolderFactory() {} | ||
| 1609 | - virtual ~ValueHolderFactory() {} | ||
| 1608 | + ValueHolderFactory() = default; | ||
| 1609 | + virtual ~ValueHolderFactory() = default; | ||
| 1610 | 1610 | virtual ValueHolder* MakeNewHolder() const = 0; | |
| 1611 | 1611 | ||
| 1612 | 1612 | private: | |
@@ -1616,7 +1616,7 @@ class [[nodiscard]] ThreadLocal : public ThreadLocalBase { | |||
| 1616 | 1616 | ||
| 1617 | 1617 | class DefaultValueHolderFactory : public ValueHolderFactory { | |
| 1618 | 1618 | public: | |
| 1619 | - DefaultValueHolderFactory() {} | ||
| 1619 | + DefaultValueHolderFactory() = default; | ||
| 1620 | 1620 | ValueHolder* MakeNewHolder() const override { return new ValueHolder(); } | |
| 1621 | 1621 | ||
| 1622 | 1622 | private: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments