Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5445)

Unified Diff: base/test/gtest_util.h

Issue 2162053006: Move EXPECT_DCHECK_DEATH from base/task_scheduler and use it in relevant base/ tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile (refer to |statement| in non-dcheck builds) Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/task_scheduler/test_utils.h ('k') | base/threading/non_thread_safe_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/gtest_util.h
diff --git a/base/test/gtest_util.h b/base/test/gtest_util.h
index f353d8364307dfc39269d71e6d84a448f6cb93b7..7753dd2e22260193f3dcf49301d38d3ae3ecff3d 100644
--- a/base/test/gtest_util.h
+++ b/base/test/gtest_util.h
@@ -10,6 +10,26 @@
#include <vector>
#include "base/compiler_specific.h"
+#include "base/logging.h"
+#include "build/build_config.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+// EXPECT/ASSERT_DCHECK_DEATH is intended to replace EXPECT/ASSERT_DEBUG_DEATH
+// when the death is expected to be caused by a DCHECK. Contrary to
+// EXPECT/ASSERT_DEBUG_DEATH however, it doesn't execute the statement in non-
+// dcheck builds as DCHECKs are intended to catch things that should never
+// happen and as such executing the statement results in undefined behavior
+// (|statement| is compiled in unsupported configurations nonetheless).
+// Death tests misbehave on Android.
+#if DCHECK_IS_ON() && defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID)
+#define EXPECT_DCHECK_DEATH(statement, regex) EXPECT_DEATH(statement, regex)
+#define ASSERT_DCHECK_DEATH(statement, regex) ASSERT_DEATH(statement, regex)
+#else
+#define EXPECT_DCHECK_DEATH(statement, regex) \
+ GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, )
+#define ASSERT_DCHECK_DEATH(statement, regex) \
+ GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, return)
gab 2016/07/20 21:21:08 This won't compile, locally I moved this from test
+#endif
namespace base {
« no previous file with comments | « base/task_scheduler/test_utils.h ('k') | base/threading/non_thread_safe_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698