Relanding #128202 Adding support for enum class in RTC_CHECK and RTC_LOG.

This is a reland of: https://webrtc-review.googlesource.com/c/src/+/128202
Logging unit test has been fixed to unregister the log listener.

Bug: webrtc:10418
Change-Id: Idac9cb71807e16a585ccb7e3e4271aa45d69f547
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/128541
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Amit Hilbuch <amithi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27192}
This commit is contained in:
Amit Hilbuch
2019-03-18 13:09:18 -07:00
committed by Commit Bot
parent 1f850a6dc7
commit 10c5a93eb7
3 changed files with 58 additions and 24 deletions

View File

@ -368,4 +368,18 @@ TEST(LogTest, Perf) {
<< " total bytes logged: " << str.size();
}
TEST(LogTest, EnumsAreSupported) {
enum class TestEnum { kValue0 = 0, kValue1 = 1 };
std::string str;
LogSinkImpl<StringStream> stream(&str);
LogMessage::AddLogToStream(&stream, LS_INFO);
RTC_LOG(LS_INFO) << "[" << TestEnum::kValue0 << "]";
EXPECT_NE(std::string::npos, str.find("[0]"));
EXPECT_EQ(std::string::npos, str.find("[1]"));
RTC_LOG(LS_INFO) << "[" << TestEnum::kValue1 << "]";
EXPECT_NE(std::string::npos, str.find("[1]"));
LogMessage::RemoveLogToStream(&stream);
stream.Close();
}
} // namespace rtc