summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2013-02-28 23:46:07 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2013-02-28 23:46:07 +0000
commit2733a36231e9e59dfe0648562ac021ccea0e27d8 (patch)
tree6758198925bed7d581f7f9d81580a726592236e8 /src
parent99788d751da80001db223de2cd6178046ff5bad0 (diff)
downloadgtest-2733a36231e9e59dfe0648562ac021ccea0e27d8.tar.gz
gtest-2733a36231e9e59dfe0648562ac021ccea0e27d8.tar.bz2
gtest-2733a36231e9e59dfe0648562ac021ccea0e27d8.tar.xz
Fixes a nasty issue in gtest's template instantiation.
git-svn-id: http://googletest.googlecode.com/svn/trunk@642 861a406c-534a-0410-8894-cb66d6ee9925
Diffstat (limited to 'src')
-rw-r--r--src/gtest-filepath.cc1
-rw-r--r--src/gtest.cc28
2 files changed, 29 insertions, 0 deletions
diff --git a/src/gtest-filepath.cc b/src/gtest-filepath.cc
index 708389d..6be58b6 100644
--- a/src/gtest-filepath.cc
+++ b/src/gtest-filepath.cc
@@ -29,6 +29,7 @@
//
// Authors: keith.ray@gmail.com (Keith Ray)
+#include "gtest/gtest-message.h"
#include "gtest/internal/gtest-filepath.h"
#include "gtest/internal/gtest-port.h"
diff --git a/src/gtest.cc b/src/gtest.cc
index 1ade269..8e6db0c 100644
--- a/src/gtest.cc
+++ b/src/gtest.cc
@@ -44,6 +44,8 @@
#include <wctype.h>
#include <algorithm>
+#include <iomanip>
+#include <limits>
#include <ostream> // NOLINT
#include <sstream>
#include <vector>
@@ -886,6 +888,26 @@ static void StreamWideCharsToMessage(const wchar_t* wstr, size_t length,
} // namespace internal
+// Constructs an empty Message.
+// We allocate the stringstream separately because otherwise each use of
+// ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's
+// stack frame leading to huge stack frames in some cases; gcc does not reuse
+// the stack space.
+Message::Message() : ss_(new ::std::stringstream) {
+ // By default, we want there to be enough precision when printing
+ // a double to a Message.
+ *ss_ << std::setprecision(std::numeric_limits<double>::digits10 + 2);
+}
+
+// These two overloads allow streaming a wide C string to a Message
+// using the UTF-8 encoding.
+Message& Message::operator <<(const wchar_t* wide_c_str) {
+ return *this << internal::String::ShowWideCString(wide_c_str);
+}
+Message& Message::operator <<(wchar_t* wide_c_str) {
+ return *this << internal::String::ShowWideCString(wide_c_str);
+}
+
#if GTEST_HAS_STD_WSTRING
// Converts the given wide string to a narrow string using the UTF-8
// encoding, and streams the result to this Message object.
@@ -904,6 +926,12 @@ Message& Message::operator <<(const ::wstring& wstr) {
}
#endif // GTEST_HAS_GLOBAL_WSTRING
+// Gets the text streamed to this object so far as an std::string.
+// Each '\0' character in the buffer is replaced with "\\0".
+std::string Message::GetString() const {
+ return internal::StringStreamToString(ss_.get());
+}
+
// AssertionResult constructors.
// Used in EXPECT_TRUE/FALSE(assertion_result).
AssertionResult::AssertionResult(const AssertionResult& other)