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

Unified Diff: base/logging_unittest.cc

Issue 1436403003: Make scoped enums output streamable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Meh Created 4 years, 8 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/logging.h ('k') | base/task_scheduler/task_traits.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/logging_unittest.cc
diff --git a/base/logging_unittest.cc b/base/logging_unittest.cc
index 22fb855b62afea792fb1708b5948f79d8a1f2848..354f6c7d6fcc339d24792a48e392d96af076e6c6 100644
--- a/base/logging_unittest.cc
+++ b/base/logging_unittest.cc
@@ -2,8 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/compiler_specific.h"
#include "base/logging.h"
+
+#include <sstream>
+
+#include "base/compiler_specific.h"
#include "base/macros.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -276,6 +279,26 @@ TEST_F(LoggingTest, CheckEqStatements) {
CHECK_EQ(false, true); // Unreached.
}
+// Test that scoped enums can be logged.
+TEST_F(LoggingTest, ScopedEnum) {
+#if 0
+ std::ostringstream ss1;
+ // Default underlying type is int.
+ enum class SignedTestEnum {
+ Value = -1,
+ };
+ ss1 << SignedTestEnum::Value;
+ EXPECT_EQ("-1", ss1.str());
+
+ std::ostringstream ss2;
+ enum class UnsignedTestEnum : unsigned {
+ Value = -1, // This is intentional.
+ };
+ ss2 << UnsignedTestEnum::Value;
+ EXPECT_EQ("0xffffffff", ss2.str());
+#endif
+}
+
// Test that defining an operator<< for a type in a namespace doesn't prevent
// other code in that namespace from calling the operator<<(ostream, wstring)
// defined by logging.h. This can fail if operator<<(ostream, wstring) can't be
« no previous file with comments | « base/logging.h ('k') | base/task_scheduler/task_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698