diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/bind_internal.h | 1 | ||||
-rw-r--r-- | base/bind_internal.h.pump | 1 | ||||
-rw-r--r-- | base/bind_unittest.cc | 12 |
3 files changed, 14 insertions, 0 deletions
diff --git a/base/bind_internal.h b/base/bind_internal.h index 4e155ab..301b681 100644 --- a/base/bind_internal.h +++ b/base/bind_internal.h @@ -814,6 +814,7 @@ MakeRunnable(const IgnoreResultHelper<T>& t) { template <typename T> const typename FunctorTraits<Callback<T> >::RunnableType& MakeRunnable(const Callback<T>& t) { + DCHECK(!t.is_null()); return t; } diff --git a/base/bind_internal.h.pump b/base/bind_internal.h.pump index 0712027..ac228e6e 100644 --- a/base/bind_internal.h.pump +++ b/base/bind_internal.h.pump @@ -258,6 +258,7 @@ MakeRunnable(const IgnoreResultHelper<T>& t) { template <typename T> const typename FunctorTraits<Callback<T> >::RunnableType& MakeRunnable(const Callback<T>& t) { + DCHECK(!t.is_null()); return t; } diff --git a/base/bind_unittest.cc b/base/bind_unittest.cc index 0f91b2e..1d808a6 100644 --- a/base/bind_unittest.cc +++ b/base/bind_unittest.cc @@ -798,5 +798,17 @@ TEST_F(BindTest, WindowsCallingConventions) { } #endif +#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && GTEST_HAS_DEATH_TEST + +// Test null callbacks cause a DCHECK. +TEST(BindDeathTest, NullCallback) { + base::Callback<void(int)> null_cb; + ASSERT_TRUE(null_cb.is_null()); + EXPECT_DEATH(base::Bind(null_cb, 42), ""); +} + +#endif // (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && + // GTEST_HAS_DEATH_TEST + } // namespace } // namespace base |