Skip to content

Commit

Permalink
Removes all uses of StrStream; fixes the VC projects and simplifies t…
Browse files Browse the repository at this point in the history
…hem by using gtest-all.cc.

git-svn-id: http://googletest.googlecode.com/svn/trunk@481 861a406c-534a-0410-8894-cb66d6ee9925
  • Loading branch information
zhanyong.wan committed Sep 8, 2010
1 parent 5d0c3dc commit b15c733
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 332 deletions.
25 changes: 12 additions & 13 deletions include/gtest/gtest-message.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace testing {
// Typical usage:
//
// 1. You stream a bunch of values to a Message object.
// It will remember the text in a StrStream.
// It will remember the text in a stringstream.
// 2. Then you stream the Message object to an ostream.
// This causes the text in the Message to be streamed
// to the ostream.
Expand All @@ -74,7 +74,7 @@ namespace testing {
// Message is not intended to be inherited from. In particular, its
// destructor is not virtual.
//
// Note that StrStream behaves differently in gcc and in MSVC. You
// Note that stringstream behaves differently in gcc and in MSVC. You
// can stream a NULL char pointer to it in the former, but not in the
// latter (it causes an access violation if you do). The Message
// class hides this difference by treating a NULL char pointer as
Expand All @@ -87,27 +87,26 @@ class GTEST_API_ Message {

public:
// Constructs an empty Message.
// We allocate the StrStream separately because it otherwise each use of
// 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() : ss_(new internal::StrStream) {
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);
}

// Copy constructor.
Message(const Message& msg) : ss_(new internal::StrStream) { // NOLINT
Message(const Message& msg) : ss_(new ::std::stringstream) { // NOLINT
*ss_ << msg.GetString();
}

// Constructs a Message from a C-string.
explicit Message(const char* str) : ss_(new internal::StrStream) {
explicit Message(const char* str) : ss_(new ::std::stringstream) {
*ss_ << str;
}

~Message() { delete ss_; }
#if GTEST_OS_SYMBIAN
// Streams a value (either a pointer or not) to this object.
template <typename T>
Expand All @@ -119,7 +118,7 @@ class GTEST_API_ Message {
// Streams a non-pointer value to this object.
template <typename T>
inline Message& operator <<(const T& val) {
::GTestStreamToHelper(ss_, val);
::GTestStreamToHelper(ss_.get(), val);
return *this;
}

Expand All @@ -141,7 +140,7 @@ class GTEST_API_ Message {
if (pointer == NULL) {
*ss_ << "(null)";
} else {
::GTestStreamToHelper(ss_, pointer);
::GTestStreamToHelper(ss_.get(), pointer);
}
return *this;
}
Expand Down Expand Up @@ -189,7 +188,7 @@ class GTEST_API_ Message {
//
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
internal::String GetString() const {
return internal::StrStreamToString(ss_);
return internal::StringStreamToString(ss_.get());
}

private:
Expand All @@ -203,17 +202,17 @@ class GTEST_API_ Message {
if (pointer == NULL) {
*ss_ << "(null)";
} else {
::GTestStreamToHelper(ss_, pointer);
::GTestStreamToHelper(ss_.get(), pointer);
}
}
template <typename T>
inline void StreamHelper(internal::false_type /*dummy*/, const T& value) {
::GTestStreamToHelper(ss_, value);
::GTestStreamToHelper(ss_.get(), value);
}
#endif // GTEST_OS_SYMBIAN

// We'll hold the text streamed to this object here.
internal::StrStream* const ss_;
const internal::scoped_ptr< ::std::stringstream> ss_;

// We declare (but don't implement) this to prevent the compiler
// from implementing the assignment operator.
Expand Down
8 changes: 4 additions & 4 deletions include/gtest/gtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -1517,18 +1517,18 @@ AssertionResult CmpHelperFloatingPointEQ(const char* expected_expression,
return AssertionSuccess();
}

StrStream expected_ss;
::std::stringstream expected_ss;
expected_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
<< expected;

StrStream actual_ss;
::std::stringstream actual_ss;
actual_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
<< actual;

return EqFailure(expected_expression,
actual_expression,
StrStreamToString(&expected_ss),
StrStreamToString(&actual_ss),
StringStreamToString(&expected_ss),
StringStreamToString(&actual_ss),
false);
}

Expand Down
2 changes: 0 additions & 2 deletions include/gtest/internal/gtest-port.h
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,6 @@ typedef ::wstring wstring;
typedef ::std::wstring wstring;
#endif // GTEST_HAS_GLOBAL_WSTRING

typedef ::std::stringstream StrStream;

// A helper for suppressing warnings on constant condition. It just
// returns 'condition'.
GTEST_API_ bool IsTrue(bool condition);
Expand Down
4 changes: 2 additions & 2 deletions include/gtest/internal/gtest-string.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ inline ::std::ostream& operator<<(::std::ostream& os, const String& str) {
return os;
}

// Gets the content of the StrStream's buffer as a String. Each '\0'
// Gets the content of the stringstream's buffer as a String. Each '\0'
// character in the buffer is replaced with "\\0".
GTEST_API_ String StrStreamToString(StrStream* stream);
GTEST_API_ String StringStreamToString(::std::stringstream* stream);

// Converts a streamable value to a String. A NULL pointer is
// converted to "(null)". When the input value is a ::string,
Expand Down
113 changes: 1 addition & 112 deletions msvc/gtest-md.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,82 +100,7 @@
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath="..\src\gtest-death-test.cc">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\gtest-filepath.cc">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\gtest-port.cc">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\gtest-test-part.cc">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\gtest-typed-test.cc">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\gtest.cc">
RelativePath="..\src\gtest-all.cc">
<FileConfiguration
Name="Debug|Win32">
<Tool
Expand All @@ -194,42 +119,6 @@
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath="..\include\gtest\internal\gtest-death-test-internal.h">
</File>
<File
RelativePath="..\include\gtest\gtest-death-test.h">
</File>
<File
RelativePath="..\include\gtest\internal\gtest-filepath.h">
</File>
<File
RelativePath="..\src\gtest-internal-inl.h">
</File>
<File
RelativePath="..\include\gtest\internal\gtest-internal.h">
</File>
<File
RelativePath="..\include\gtest\gtest-message.h">
</File>
<File
RelativePath="..\include\gtest\internal\gtest-port.h">
</File>
<File
RelativePath="..\include\gtest\gtest-spi.h">
</File>
<File
RelativePath="..\include\gtest\internal\gtest-string.h">
</File>
<File
RelativePath="..\include\gtest\gtest.h">
</File>
<File
RelativePath="..\include\gtest\gtest_pred_impl.h">
</File>
<File
RelativePath="..\include\gtest\gtest_prod.h">
</File>
</Filter>
</Files>
<Globals>
Expand Down
113 changes: 1 addition & 112 deletions msvc/gtest.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,82 +100,7 @@
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath="..\src\gtest-death-test.cc">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\gtest-filepath.cc">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\gtest-test-part.cc">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\gtest-port.cc">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\gtest-typed-test.cc">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..&quot;;&quot;..\include&quot;"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\gtest.cc">
RelativePath="..\src\gtest-all.cc">
<FileConfiguration
Name="Debug|Win32">
<Tool
Expand All @@ -194,42 +119,6 @@
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath="..\include\gtest\internal\gtest-death-test-internal.h">
</File>
<File
RelativePath="..\include\gtest\gtest-death-test.h">
</File>
<File
RelativePath="..\include\gtest\internal\gtest-filepath.h">
</File>
<File
RelativePath="..\src\gtest-internal-inl.h">
</File>
<File
RelativePath="..\include\gtest\internal\gtest-internal.h">
</File>
<File
RelativePath="..\include\gtest\gtest-message.h">
</File>
<File
RelativePath="..\include\gtest\internal\gtest-port.h">
</File>
<File
RelativePath="..\include\gtest\gtest-spi.h">
</File>
<File
RelativePath="..\include\gtest\internal\gtest-string.h">
</File>
<File
RelativePath="..\include\gtest\gtest.h">
</File>
<File
RelativePath="..\include\gtest\gtest_pred_impl.h">
</File>
<File
RelativePath="..\include\gtest\gtest_prod.h">
</File>
</Filter>
</Files>
<Globals>
Expand Down
Loading

0 comments on commit b15c733

Please sign in to comment.