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

Side by Side Diff: base/logging_unittest.cc

Issue 2001783002: base: Support using (D)CHECK on scoped enums. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use CR_GLIBCXX_4_7_0 macro, since I bothered to define it Created 4 years, 7 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
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/compiler_specific.h" 5 #include "base/compiler_specific.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/macros.h" 7 #include "base/macros.h"
8 8
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 244
245 // Test DCHECK on std::nullptr_t 245 // Test DCHECK on std::nullptr_t
246 log_sink_call_count = 0; 246 log_sink_call_count = 0;
247 const void* p_null = nullptr; 247 const void* p_null = nullptr;
248 const void* p_not_null = &p_null; 248 const void* p_not_null = &p_null;
249 DCHECK_EQ(p_null, nullptr); 249 DCHECK_EQ(p_null, nullptr);
250 DCHECK_EQ(nullptr, p_null); 250 DCHECK_EQ(nullptr, p_null);
251 DCHECK_NE(p_not_null, nullptr); 251 DCHECK_NE(p_not_null, nullptr);
252 DCHECK_NE(nullptr, p_not_null); 252 DCHECK_NE(nullptr, p_not_null);
253 EXPECT_EQ(0, log_sink_call_count); 253 EXPECT_EQ(0, log_sink_call_count);
254
255 // Test DCHECK on a scoped enum.
256 enum class Animal { DOG, CAT };
257 DCHECK_EQ(Animal::DOG, Animal::DOG);
258 EXPECT_EQ(0, log_sink_call_count);
259 DCHECK_EQ(Animal::DOG, Animal::CAT);
260 EXPECT_EQ(DCHECK_IS_ON() ? 1 : 0, log_sink_call_count);
254 } 261 }
255 262
256 TEST_F(LoggingTest, DcheckReleaseBehavior) { 263 TEST_F(LoggingTest, DcheckReleaseBehavior) {
257 int some_variable = 1; 264 int some_variable = 1;
258 // These should still reference |some_variable| so we don't get 265 // These should still reference |some_variable| so we don't get
259 // unused variable warnings. 266 // unused variable warnings.
260 DCHECK(some_variable) << "test"; 267 DCHECK(some_variable) << "test";
261 DPCHECK(some_variable) << "test"; 268 DPCHECK(some_variable) << "test";
262 DCHECK_EQ(some_variable, 1) << "test"; 269 DCHECK_EQ(some_variable, 1) << "test";
263 } 270 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 std::wstring wstr = L"Hello World"; 308 std::wstring wstr = L"Hello World";
302 std::ostringstream ostr; 309 std::ostringstream ostr;
303 ostr << wstr; 310 ostr << wstr;
304 EXPECT_EQ("Hello World", ostr.str()); 311 EXPECT_EQ("Hello World", ostr.str());
305 } 312 }
306 } // namespace nested_test 313 } // namespace nested_test
307 314
308 } // namespace 315 } // namespace
309 316
310 } // namespace logging 317 } // namespace logging
OLDNEW
« base/logging.h ('K') | « base/logging.cc ('k') | base/template_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698