diff options
author | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2010-01-08 00:23:45 (GMT) |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2010-01-08 00:23:45 (GMT) |
commit | e92ccedad996eeb4f0d9244a1acd8882b5f54fd0 (patch) | |
tree | a718cd0252d548885e82abe10b5ed17342dd15b0 /src/gtest.cc | |
parent | ef37aa407478b65e3042d5686ebcc95cbf1527b3 (diff) | |
download | googletest-e92ccedad996eeb4f0d9244a1acd8882b5f54fd0.zip googletest-e92ccedad996eeb4f0d9244a1acd8882b5f54fd0.tar.gz googletest-e92ccedad996eeb4f0d9244a1acd8882b5f54fd0.tar.bz2 |
Changes Message() to print double with enough precision by default.
Diffstat (limited to 'src/gtest.cc')
-rw-r--r-- | src/gtest.cc | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/gtest.cc b/src/gtest.cc index c6d6c09..11ce571 100644 --- a/src/gtest.cc +++ b/src/gtest.cc @@ -43,6 +43,7 @@ #include <wctype.h> #include <ostream> +#include <sstream> #if GTEST_OS_LINUX @@ -3168,14 +3169,11 @@ String XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters(const char* str) { // </testsuite> // </testsuites> -// Formats the given time in milliseconds as seconds. The returned -// C-string is owned by this function and cannot be released by the -// caller. Calling the function again invalidates the previous -// result. -const char* FormatTimeInMillisAsSeconds(TimeInMillis ms) { - static String str; - str = (Message() << (ms/1000.0)).GetString(); - return str.c_str(); +// Formats the given time in milliseconds as seconds. +std::string FormatTimeInMillisAsSeconds(TimeInMillis ms) { + ::std::stringstream ss; + ss << ms/1000.0; + return ss.str(); } // Streams an XML CDATA section, escaping invalid CDATA sequences as needed. @@ -3249,7 +3247,7 @@ void XmlUnitTestResultPrinter::PrintXmlTestCase(FILE* out, test_case.disabled_test_count()); fprintf(out, "errors=\"0\" time=\"%s\">\n", - FormatTimeInMillisAsSeconds(test_case.elapsed_time())); + FormatTimeInMillisAsSeconds(test_case.elapsed_time()).c_str()); for (int i = 0; i < test_case.total_test_count(); ++i) { StrStream stream; OutputXmlTestInfo(&stream, test_case.name(), *test_case.GetTestInfo(i)); @@ -3268,7 +3266,7 @@ void XmlUnitTestResultPrinter::PrintXmlUnitTest(FILE* out, unit_test.total_test_count(), unit_test.failed_test_count(), unit_test.disabled_test_count(), - FormatTimeInMillisAsSeconds(unit_test.elapsed_time())); + FormatTimeInMillisAsSeconds(unit_test.elapsed_time()).c_str()); if (GTEST_FLAG(shuffle)) { fprintf(out, "random_seed=\"%d\" ", unit_test.random_seed()); } |