diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-27 20:12:38 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-27 20:12:38 +0000 |
commit | 1925665151e3f15626abb722d99b064825bea07b (patch) | |
tree | 757fb1e260a0642a7d19ec0c6fe81918a93a5a2b /base/thread_collision_warner_unittest.cc | |
parent | a4a1cd226a145f12fc26d20a527e1383a120e7c3 (diff) | |
download | chromium_src-1925665151e3f15626abb722d99b064825bea07b.zip chromium_src-1925665151e3f15626abb722d99b064825bea07b.tar.gz chromium_src-1925665151e3f15626abb722d99b064825bea07b.tar.bz2 |
Reduce the amount of #ifdef.
Review URL: http://codereview.chromium.org/18852
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8743 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/thread_collision_warner_unittest.cc')
-rw-r--r-- | base/thread_collision_warner_unittest.cc | 56 |
1 files changed, 21 insertions, 35 deletions
diff --git a/base/thread_collision_warner_unittest.cc b/base/thread_collision_warner_unittest.cc index 69e85f0..45b3823 100644 --- a/base/thread_collision_warner_unittest.cc +++ b/base/thread_collision_warner_unittest.cc @@ -12,6 +12,24 @@ // '' : local class member function does not have a body MSVC_PUSH_DISABLE_WARNING(4822) + +#if defined(NDEBUG) + +// Would cause a memory leak otherwise. +#undef DFAKE_MUTEX +#define DFAKE_MUTEX(obj) scoped_ptr<base::AsserterBase> obj + +// In Release, we expect the AsserterBase::warn() to not happen. +#define EXPECT_NDEBUG_FALSE_DEBUG_TRUE EXPECT_FALSE + +#else + +// In Debug, we expect the AsserterBase::warn() to happen. +#define EXPECT_NDEBUG_FALSE_DEBUG_TRUE EXPECT_TRUE + +#endif + + namespace { // This is the asserter used with ThreadCollisionWarner instead of the default @@ -92,11 +110,7 @@ TEST(ThreadCollisionTest, ScopedBookCriticalSection) { { // Pin section again (not allowed by DFAKE_SCOPED_LOCK) DFAKE_SCOPED_LOCK(warner); -#if !defined(NDEBUG) - EXPECT_TRUE(local_reporter->fail_state()); -#else - EXPECT_FALSE(local_reporter->fail_state()); -#endif + EXPECT_NDEBUG_FALSE_DEBUG_TRUE(local_reporter->fail_state()); // Reset the status of warner for further tests. local_reporter->reset(); } // Unpin section. @@ -113,12 +127,7 @@ TEST(ThreadCollisionTest, MTBookCriticalSectionTest) { class NonThreadSafeQueue { public: explicit NonThreadSafeQueue(base::AsserterBase* asserter) -#if !defined(NDEBUG) : push_pop_(asserter) { -#else - { - delete asserter; -#endif } void push(int value) { @@ -166,11 +175,7 @@ TEST(ThreadCollisionTest, MTBookCriticalSectionTest) { thread_a.Join(); thread_b.Join(); -#if !defined(NDEBUG) - EXPECT_TRUE(local_reporter->fail_state()); -#else - EXPECT_FALSE(local_reporter->fail_state()); -#endif + EXPECT_NDEBUG_FALSE_DEBUG_TRUE(local_reporter->fail_state()); } TEST(ThreadCollisionTest, MTScopedBookCriticalSectionTest) { @@ -179,12 +184,7 @@ TEST(ThreadCollisionTest, MTScopedBookCriticalSectionTest) { class NonThreadSafeQueue { public: explicit NonThreadSafeQueue(base::AsserterBase* asserter) -#if !defined(NDEBUG) : push_pop_(asserter) { -#else - { - delete asserter; -#endif } void push(int value) { @@ -233,11 +233,7 @@ TEST(ThreadCollisionTest, MTScopedBookCriticalSectionTest) { thread_a.Join(); thread_b.Join(); -#if !defined(NDEBUG) - EXPECT_TRUE(local_reporter->fail_state()); -#else - EXPECT_FALSE(local_reporter->fail_state()); -#endif + EXPECT_NDEBUG_FALSE_DEBUG_TRUE(local_reporter->fail_state()); } TEST(ThreadCollisionTest, MTSynchedScopedBookCriticalSectionTest) { @@ -246,12 +242,7 @@ TEST(ThreadCollisionTest, MTSynchedScopedBookCriticalSectionTest) { class NonThreadSafeQueue { public: explicit NonThreadSafeQueue(base::AsserterBase* asserter) -#if !defined(NDEBUG) : push_pop_(asserter) { -#else - { - delete asserter; -#endif } void push(int value) { @@ -320,12 +311,7 @@ TEST(ThreadCollisionTest, MTSynchedScopedRecursiveBookCriticalSectionTest) { class NonThreadSafeQueue { public: explicit NonThreadSafeQueue(base::AsserterBase* asserter) -#if !defined(NDEBUG) : push_pop_(asserter) { -#else - { - delete asserter; -#endif } void push(int) { |