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

Side by Side Diff: base/logging_unittest.cc

Issue 7719007: Add a gyp flag to enable dcheck by default in release without (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/logging.h ('k') | build/common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 7
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // in release mode. 190 // in release mode.
191 DLOG_IF(INFO, debug_only_variable) << "test"; 191 DLOG_IF(INFO, debug_only_variable) << "test";
192 DLOG_ASSERT(debug_only_variable) << "test"; 192 DLOG_ASSERT(debug_only_variable) << "test";
193 DPLOG_IF(INFO, debug_only_variable) << "test"; 193 DPLOG_IF(INFO, debug_only_variable) << "test";
194 DVLOG_IF(1, debug_only_variable) << "test"; 194 DVLOG_IF(1, debug_only_variable) << "test";
195 } 195 }
196 196
197 TEST_F(LoggingTest, DcheckStreamsAreLazy) { 197 TEST_F(LoggingTest, DcheckStreamsAreLazy) {
198 MockLogSource mock_log_source; 198 MockLogSource mock_log_source;
199 EXPECT_CALL(mock_log_source, Log()).Times(0); 199 EXPECT_CALL(mock_log_source, Log()).Times(0);
200 200 #if !defined(LOGGING_IS_OFFICIAL_BUILD) && defined(NDEBUG) && \
201 #if !defined(LOGGING_IS_OFFICIAL_BUILD) && defined(NDEBUG) 201 !defined(DCHECK_ALWAYS_ON)
202 // Unofficial release build. 202 // Unofficial release build without dcheck enabled.
203 g_dcheck_state = DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; 203 g_dcheck_state = DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS;
204 DCHECK(mock_log_source.Log()) << mock_log_source.Log(); 204 DCHECK(mock_log_source.Log()) << mock_log_source.Log();
205 DPCHECK(mock_log_source.Log()) << mock_log_source.Log(); 205 DPCHECK(mock_log_source.Log()) << mock_log_source.Log();
206 DCHECK_EQ(0, 0) << mock_log_source.Log(); 206 DCHECK_EQ(0, 0) << mock_log_source.Log();
207 DCHECK_EQ(mock_log_source.Log(), static_cast<const char*>(NULL)) 207 DCHECK_EQ(mock_log_source.Log(), static_cast<const char*>(NULL))
208 << mock_log_source.Log(); 208 << mock_log_source.Log();
209 #endif // !defined(LOGGING_IS_OFFICIAL_BUILD) && defined(NDEBUG) 209 #endif // !defined(LOGGING_IS_OFFICIAL_BUILD) && defined(NDEBUG) && \
rvargas (doing something else) 2011/08/24 00:49:37 nit: personally, I'd remove this comment.
210 // !defined(DCHECK_ALWAYS_ON)
210 } 211 }
211 212
212 TEST_F(LoggingTest, Dcheck) { 213 TEST_F(LoggingTest, Dcheck) {
213 #if defined(LOGGING_IS_OFFICIAL_BUILD) 214 #if defined(LOGGING_IS_OFFICIAL_BUILD)
214 // Official build. 215 // Official build.
215 EXPECT_FALSE(DCHECK_IS_ON()); 216 EXPECT_FALSE(DCHECK_IS_ON());
216 EXPECT_FALSE(DLOG_IS_ON(DCHECK)); 217 EXPECT_FALSE(DLOG_IS_ON(DCHECK));
217 #elif defined(NDEBUG) 218 #elif defined(NDEBUG)
218 // Unofficial release build. 219 // Unofficial release build.
219 g_dcheck_state = ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; 220 g_dcheck_state = ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS;
(...skipping 21 matching lines...) Expand all
241 // These should still reference |some_variable| so we don't get 242 // These should still reference |some_variable| so we don't get
242 // unused variable warnings. 243 // unused variable warnings.
243 DCHECK(some_variable) << "test"; 244 DCHECK(some_variable) << "test";
244 DPCHECK(some_variable) << "test"; 245 DPCHECK(some_variable) << "test";
245 DCHECK_EQ(some_variable, 1) << "test"; 246 DCHECK_EQ(some_variable, 1) << "test";
246 } 247 }
247 248
248 } // namespace 249 } // namespace
249 250
250 } // namespace logging 251 } // namespace logging
OLDNEW
« no previous file with comments | « base/logging.h ('k') | build/common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698