diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-22 18:32:21 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-22 18:32:21 +0000 |
commit | 22015c33fe44a1cc36596e0b6de37a48dc13b131 (patch) | |
tree | 643966e3ad01ab48b4f1d0ab48793261c68cee02 /testing/gmock/src | |
parent | ad764d54ec391e95e4ea239aa8eed548ce45cb61 (diff) | |
download | chromium_src-22015c33fe44a1cc36596e0b6de37a48dc13b131.zip chromium_src-22015c33fe44a1cc36596e0b6de37a48dc13b131.tar.gz chromium_src-22015c33fe44a1cc36596e0b6de37a48dc13b131.tar.bz2 |
Upgrade gtest to r267 and gmock to r173.
This is step1 into removing the boost + tr1 dependency in windows. It also includes a hack to avoid brining in tr1/functional on gcc, which will move us closer to enabling -fno-rtti.
This CL has passed the try servers. I've also tried compiling gmock, gmock_main, base, base_unittests, and webcore modules in vs2008 express editions.
Review URL: http://codereview.chromium.org/140003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18923 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'testing/gmock/src')
-rw-r--r-- | testing/gmock/src/gmock-internal-utils.cc | 44 | ||||
-rw-r--r-- | testing/gmock/src/gmock-printers.cc | 5 | ||||
-rw-r--r-- | testing/gmock/src/gmock-spec-builders.cc | 4 |
3 files changed, 34 insertions, 19 deletions
diff --git a/testing/gmock/src/gmock-internal-utils.cc b/testing/gmock/src/gmock-internal-utils.cc index 735abce..0e693c7 100644 --- a/testing/gmock/src/gmock-internal-utils.cc +++ b/testing/gmock/src/gmock-internal-utils.cc @@ -101,6 +101,22 @@ FailureReporterInterface* GetFailureReporter() { // Protects global resources (stdout in particular) used by Log(). static Mutex g_log_mutex(Mutex::NO_CONSTRUCTOR_NEEDED_FOR_STATIC_MUTEX); +// Returns true iff a log with the given severity is visible according +// to the --gmock_verbose flag. +bool LogIsVisible(LogSeverity severity) { + if (GMOCK_FLAG(verbose) == kInfoVerbosity) { + // Always show the log if --gmock_verbose=info. + return true; + } else if (GMOCK_FLAG(verbose) == kErrorVerbosity) { + // Always hide it if --gmock_verbose=error. + return false; + } else { + // If --gmock_verbose is neither "info" nor "error", we treat it + // as "warning" (its default value). + return severity == WARNING; + } +} + // Prints the given message to stdout iff 'severity' >= the level // specified by the --gmock_verbose flag. If stack_frames_to_skip >= // 0, also prints the stack trace excluding the top @@ -110,30 +126,24 @@ static Mutex g_log_mutex(Mutex::NO_CONSTRUCTOR_NEEDED_FOR_STATIC_MUTEX); // conservative. void Log(LogSeverity severity, const string& message, int stack_frames_to_skip) { - if (GMOCK_FLAG(verbose) == kErrorVerbosity) { - // The user is not interested in logs. + if (!LogIsVisible(severity)) return; - } else if (GMOCK_FLAG(verbose) != kInfoVerbosity) { - // The user is interested in warnings but not informational logs. - // Note that invalid values of GMOCK_FLAG(verbose) are treated as - // "warning", which is the default value of the flag. - if (severity == INFO) { - return; - } - } // Ensures that logs from different threads don't interleave. MutexLock l(&g_log_mutex); - using ::std::cout; + + // "using ::std::cout;" doesn't work with Symbian's STLport, where cout is a + // macro. + if (severity == WARNING) { // Prints a GMOCK WARNING marker to make the warnings easily searchable. - cout << "\nGMOCK WARNING:"; + std::cout << "\nGMOCK WARNING:"; } // Pre-pends a new-line to message if it doesn't start with one. if (message.empty() || message[0] != '\n') { - cout << "\n"; + std::cout << "\n"; } - cout << message; + std::cout << message; if (stack_frames_to_skip >= 0) { #ifdef NDEBUG // In opt mode, we have to be conservative and skip no stack frame. @@ -146,13 +156,13 @@ void Log(LogSeverity severity, const string& message, // Appends a new-line to message if it doesn't end with one. if (!message.empty() && *message.rbegin() != '\n') { - cout << "\n"; + std::cout << "\n"; } - cout << "Stack trace:\n" + std::cout << "Stack trace:\n" << ::testing::internal::GetCurrentOsStackTraceExceptTop( ::testing::UnitTest::GetInstance(), actual_to_skip); } - cout << ::std::flush; + std::cout << ::std::flush; } } // namespace internal diff --git a/testing/gmock/src/gmock-printers.cc b/testing/gmock/src/gmock-printers.cc index e6d4001..922a7b2 100644 --- a/testing/gmock/src/gmock-printers.cc +++ b/testing/gmock/src/gmock-printers.cc @@ -242,6 +242,11 @@ static void PrintCharsAsStringTo(const char* begin, size_t len, ostream* os) { *os << "\""; } +// Prints a (const) char array of 'len' elements, starting at address 'begin'. +void UniversalPrintArray(const char* begin, size_t len, ostream* os) { + PrintCharsAsStringTo(begin, len, os); +} + // Prints the given array of wide characters to the ostream. // The array starts at *begin, the length is len, it may include L'\0' // characters and may not be null-terminated. diff --git a/testing/gmock/src/gmock-spec-builders.cc b/testing/gmock/src/gmock-spec-builders.cc index 65a74b8..465e4d6 100644 --- a/testing/gmock/src/gmock-spec-builders.cc +++ b/testing/gmock/src/gmock-spec-builders.cc @@ -139,10 +139,10 @@ ThreadLocal<Sequence*> g_gmock_implicit_sequence; void ReportUninterestingCall(CallReaction reaction, const string& msg) { switch (reaction) { case ALLOW: - Log(INFO, msg, 4); + Log(INFO, msg, 3); break; case WARN: - Log(WARNING, msg, 4); + Log(WARNING, msg, 3); break; default: // FAIL Expect(false, NULL, -1, msg); |