aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-08-07 06:47:47 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-08-07 06:47:47 +0000
commited8500b341c473ecf46acd13951ae5b4e3acc780 (patch)
treeca41796e67c988e8985cc084e1c6136aa609df39 /src
parent18c31d64e120919e8e04df3035234b9afe8eb6d9 (diff)
downloadgoogletest-ed8500b341c473ecf46acd13951ae5b4e3acc780.tar.gz
googletest-ed8500b341c473ecf46acd13951ae5b4e3acc780.tar.bz2
googletest-ed8500b341c473ecf46acd13951ae5b4e3acc780.zip
Implements EXPECT_DEATH_IF_SUPPORTED (by Vlad Losev); Fixes compatibility with Symbian (by Araceli Checa); Removes GetCapturedStderr()'s dependency on std::string (by Vlad Losev).
Diffstat (limited to 'src')
-rw-r--r--src/gtest-death-test.cc8
-rw-r--r--src/gtest-port.cc12
2 files changed, 6 insertions, 14 deletions
diff --git a/src/gtest-death-test.cc b/src/gtest-death-test.cc
index 0d4110bd..02ce48d5 100644
--- a/src/gtest-death-test.cc
+++ b/src/gtest-death-test.cc
@@ -452,11 +452,7 @@ bool DeathTestImpl::Passed(bool status_ok) {
if (!spawned())
return false;
-#if GTEST_HAS_GLOBAL_STRING
- const ::string error_message = GetCapturedStderr();
-#else
- const ::std::string error_message = GetCapturedStderr();
-#endif // GTEST_HAS_GLOBAL_STRING
+ const String error_message = GetCapturedStderr();
bool success = false;
Message buffer;
@@ -473,7 +469,7 @@ bool DeathTestImpl::Passed(bool status_ok) {
break;
case DIED:
if (status_ok) {
- if (RE::PartialMatch(error_message, *regex())) {
+ if (RE::PartialMatch(error_message.c_str(), *regex())) {
success = true;
} else {
buffer << " Result: died but not with expected error.\n"
diff --git a/src/gtest-port.cc b/src/gtest-port.cc
index bc6d8f80..09d1a8e0 100644
--- a/src/gtest-port.cc
+++ b/src/gtest-port.cc
@@ -431,8 +431,6 @@ void GTestLog(GTestLogSeverity severity, const char* file,
}
}
-#if GTEST_HAS_STD_STRING
-
// Disable Microsoft deprecation warnings for POSIX functions called from
// this class (creat, dup, dup2, and close)
#ifdef _MSC_VER
@@ -514,7 +512,7 @@ static size_t GetFileSize(FILE * file) {
}
// Reads the entire content of a file as a string.
-static ::std::string ReadEntireFile(FILE * file) {
+static String ReadEntireFile(FILE * file) {
const size_t file_size = GetFileSize(file);
char* const buffer = new char[file_size];
@@ -530,7 +528,7 @@ static ::std::string ReadEntireFile(FILE * file) {
bytes_read += bytes_last_read;
} while (bytes_last_read > 0 && bytes_read < file_size);
- const ::std::string content(buffer, buffer+bytes_read);
+ const String content(buffer, bytes_read);
delete[] buffer;
return content;
@@ -547,11 +545,11 @@ void CaptureStderr() {
// Stops capturing stderr and returns the captured string.
// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we can
// use it here.
-::std::string GetCapturedStderr() {
+String GetCapturedStderr() {
g_captured_stderr->StopCapture();
FILE* const file = posix::FOpen(g_captured_stderr->filename().c_str(), "r");
- const ::std::string content = ReadEntireFile(file);
+ const String content = ReadEntireFile(file);
posix::FClose(file);
delete g_captured_stderr;
@@ -560,8 +558,6 @@ void CaptureStderr() {
return content;
}
-#endif // GTEST_HAS_STD_STRING
-
#if GTEST_HAS_DEATH_TEST
// A copy of all command line arguments. Set by InitGoogleTest().