diff options
Diffstat (limited to 'src/google/protobuf/testing')
-rw-r--r-- | src/google/protobuf/testing/googletest.cc | 11 | ||||
-rw-r--r-- | src/google/protobuf/testing/googletest.h | 11 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/google/protobuf/testing/googletest.cc b/src/google/protobuf/testing/googletest.cc index cd094d0c..a8da6b1d 100644 --- a/src/google/protobuf/testing/googletest.cc +++ b/src/google/protobuf/testing/googletest.cc @@ -223,16 +223,17 @@ ScopedMemoryLog::~ScopedMemoryLog() { active_log_ = NULL; } -const vector<string>& ScopedMemoryLog::GetMessages(LogLevel dummy) const { - GOOGLE_CHECK_EQ(dummy, ERROR); - return messages_; +const vector<string>& ScopedMemoryLog::GetMessages(LogLevel level) { + GOOGLE_CHECK(level == ERROR || + level == WARNING); + return messages_[level]; } void ScopedMemoryLog::HandleLog(LogLevel level, const char* filename, int line, const string& message) { GOOGLE_CHECK(active_log_ != NULL); - if (level == ERROR) { - active_log_->messages_.push_back(message); + if (level == ERROR || level == WARNING) { + active_log_->messages_[level].push_back(message); } } diff --git a/src/google/protobuf/testing/googletest.h b/src/google/protobuf/testing/googletest.h index 71444c96..6b17ae4f 100644 --- a/src/google/protobuf/testing/googletest.h +++ b/src/google/protobuf/testing/googletest.h @@ -34,6 +34,7 @@ #ifndef GOOGLE_PROTOBUF_GOOGLETEST_H__ #define GOOGLE_PROTOBUF_GOOGLETEST_H__ +#include <map> #include <vector> #include <google/protobuf/stubs/common.h> @@ -60,6 +61,7 @@ string GetCapturedTestStderr(); // ScopedMemoryLog refers to LOGLEVEL_ERROR as just ERROR. #undef ERROR // defend against promiscuous windows.h static const LogLevel ERROR = LOGLEVEL_ERROR; +static const LogLevel WARNING = LOGLEVEL_WARNING; // Receives copies of all LOG(ERROR) messages while in scope. Sample usage: // { @@ -74,14 +76,11 @@ class ScopedMemoryLog { ScopedMemoryLog(); virtual ~ScopedMemoryLog(); - // Fetches all messages logged. The internal version of this class - // would only fetch messages at the given security level, but the protobuf - // open source version ignores the argument since we always pass ERROR - // anyway. - const vector<string>& GetMessages(LogLevel dummy) const; + // Fetches all messages with the given severity level. + const vector<string>& GetMessages(LogLevel error); private: - vector<string> messages_; + map<LogLevel, vector<string> > messages_; LogHandler* old_handler_; static void HandleLog(LogLevel level, const char* filename, int line, |