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

Side by Side Diff: base/logging_unittest.cc

Issue 6070006: Made logging not look up --enable-dcheck from command line (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed more compile failures Created 9 years, 11 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.cc ('k') | base/test/test_suite.cc » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 DPLOG_IF(INFO, debug_only_variable) << "test"; 190 DPLOG_IF(INFO, debug_only_variable) << "test";
191 DVLOG_IF(1, debug_only_variable) << "test"; 191 DVLOG_IF(1, debug_only_variable) << "test";
192 } 192 }
193 193
194 TEST_F(LoggingTest, DcheckStreamsAreLazy) { 194 TEST_F(LoggingTest, DcheckStreamsAreLazy) {
195 MockLogSource mock_log_source; 195 MockLogSource mock_log_source;
196 EXPECT_CALL(mock_log_source, Log()).Times(0); 196 EXPECT_CALL(mock_log_source, Log()).Times(0);
197 197
198 #if !defined(LOGGING_IS_OFFICIAL_BUILD) && defined(NDEBUG) 198 #if !defined(LOGGING_IS_OFFICIAL_BUILD) && defined(NDEBUG)
199 // Unofficial release build. 199 // Unofficial release build.
200 logging::g_enable_dcheck = false; 200 g_dcheck_state = DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS;
201 DCHECK(mock_log_source.Log()) << mock_log_source.Log(); 201 DCHECK(mock_log_source.Log()) << mock_log_source.Log();
202 DPCHECK(mock_log_source.Log()) << mock_log_source.Log(); 202 DPCHECK(mock_log_source.Log()) << mock_log_source.Log();
203 DCHECK_EQ(0, 0) << mock_log_source.Log(); 203 DCHECK_EQ(0, 0) << mock_log_source.Log();
204 DCHECK_EQ(mock_log_source.Log(), static_cast<const char*>(NULL)) 204 DCHECK_EQ(mock_log_source.Log(), static_cast<const char*>(NULL))
205 << mock_log_source.Log(); 205 << mock_log_source.Log();
206 #endif // !defined(LOGGING_IS_OFFICIAL_BUILD) && defined(NDEBUG) 206 #endif // !defined(LOGGING_IS_OFFICIAL_BUILD) && defined(NDEBUG)
207 } 207 }
208 208
209 TEST_F(LoggingTest, Dcheck) { 209 TEST_F(LoggingTest, Dcheck) {
210 #if defined(LOGGING_IS_OFFICIAL_BUILD) 210 #if defined(LOGGING_IS_OFFICIAL_BUILD)
211 // Official build. 211 // Official build.
212 EXPECT_FALSE(DCHECK_IS_ON()); 212 EXPECT_FALSE(DCHECK_IS_ON());
213 EXPECT_FALSE(DLOG_IS_ON(DCHECK)); 213 EXPECT_FALSE(DLOG_IS_ON(DCHECK));
214 #elif defined(NDEBUG) 214 #elif defined(NDEBUG)
215 // Unofficial release build. 215 // Unofficial release build.
216 logging::g_enable_dcheck = true; 216 g_dcheck_state = ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS;
217 logging::SetLogReportHandler(&LogSink); 217 SetLogReportHandler(&LogSink);
218 EXPECT_TRUE(DCHECK_IS_ON()); 218 EXPECT_TRUE(DCHECK_IS_ON());
219 EXPECT_FALSE(DLOG_IS_ON(DCHECK)); 219 EXPECT_FALSE(DLOG_IS_ON(DCHECK));
220 #else 220 #else
221 // Unofficial debug build. 221 // Unofficial debug build.
222 logging::SetLogAssertHandler(&LogSink); 222 SetLogAssertHandler(&LogSink);
223 EXPECT_TRUE(DCHECK_IS_ON()); 223 EXPECT_TRUE(DCHECK_IS_ON());
224 EXPECT_TRUE(DLOG_IS_ON(DCHECK)); 224 EXPECT_TRUE(DLOG_IS_ON(DCHECK));
225 #endif // defined(LOGGING_IS_OFFICIAL_BUILD) 225 #endif // defined(LOGGING_IS_OFFICIAL_BUILD)
226 226
227 EXPECT_EQ(0, log_sink_call_count); 227 EXPECT_EQ(0, log_sink_call_count);
228 DCHECK(false); 228 DCHECK(false);
229 EXPECT_EQ(DCHECK_IS_ON() ? 1 : 0, log_sink_call_count); 229 EXPECT_EQ(DCHECK_IS_ON() ? 1 : 0, log_sink_call_count);
230 DPCHECK(false); 230 DPCHECK(false);
231 EXPECT_EQ(DCHECK_IS_ON() ? 2 : 0, log_sink_call_count); 231 EXPECT_EQ(DCHECK_IS_ON() ? 2 : 0, log_sink_call_count);
232 DCHECK_EQ(0, 1); 232 DCHECK_EQ(0, 1);
233 EXPECT_EQ(DCHECK_IS_ON() ? 3 : 0, log_sink_call_count); 233 EXPECT_EQ(DCHECK_IS_ON() ? 3 : 0, log_sink_call_count);
234 } 234 }
235 235
236 TEST_F(LoggingTest, DcheckReleaseBehavior) { 236 TEST_F(LoggingTest, DcheckReleaseBehavior) {
237 int some_variable = 1; 237 int some_variable = 1;
238 // These should still reference |some_variable| so we don't get 238 // These should still reference |some_variable| so we don't get
239 // unused variable warnings. 239 // unused variable warnings.
240 DCHECK(some_variable) << "test"; 240 DCHECK(some_variable) << "test";
241 DPCHECK(some_variable) << "test"; 241 DPCHECK(some_variable) << "test";
242 DCHECK_EQ(some_variable, 1) << "test"; 242 DCHECK_EQ(some_variable, 1) << "test";
243 } 243 }
244 244
245 } // namespace 245 } // namespace
246 246
247 } // namespace logging 247 } // namespace logging
OLDNEW
« no previous file with comments | « base/logging.cc ('k') | base/test/test_suite.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698