summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorvladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2008-11-26 20:48:45 +0000
committervladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2008-11-26 20:48:45 +0000
commitf179f4ee7cc76e7103a726ebf666902b07f89659 (patch)
treed893f35c7534f4a9a3b3619ecf3331ed946d2c33 /include
parent69bc764afbe25a110920b5595abbd71fa712e085 (diff)
downloadgoogletest-f179f4ee7cc76e7103a726ebf666902b07f89659.tar.gz
Allow Google Mock to initialize Google Test
git-svn-id: http://googletest.googlecode.com/svn/trunk@139 861a406c-534a-0410-8894-cb66d6ee9925
Diffstat (limited to 'include')
-rw-r--r--include/gtest/gtest.h4
-rw-r--r--include/gtest/internal/gtest-internal.h3
-rw-r--r--include/gtest/internal/gtest-string.h22
3 files changed, 27 insertions, 2 deletions
diff --git a/include/gtest/gtest.h b/include/gtest/gtest.h
index 38fcd7d..ebd3123 100644
--- a/include/gtest/gtest.h
+++ b/include/gtest/gtest.h
@@ -554,13 +554,13 @@ inline Environment* AddGlobalTestEnvironment(Environment* env) {
//
// No value is returned. Instead, the Google Test flag variables are
// updated.
+//
+// Calling the function for the second time has no user-visible effect.
void InitGoogleTest(int* argc, char** argv);
// This overloaded version can be used in Windows programs compiled in
// UNICODE mode.
-#ifdef GTEST_OS_WINDOWS
void InitGoogleTest(int* argc, wchar_t** argv);
-#endif // GTEST_OS_WINDOWS
namespace internal {
diff --git a/include/gtest/internal/gtest-internal.h b/include/gtest/internal/gtest-internal.h
index 9e353b6..37faaae 100644
--- a/include/gtest/internal/gtest-internal.h
+++ b/include/gtest/internal/gtest-internal.h
@@ -121,6 +121,9 @@ class UnitTestImpl; // Opaque implementation of UnitTest
template <typename E> class List; // A generic list.
template <typename E> class ListNode; // A node in a generic list.
+// How many times InitGoogleTest() has been called.
+extern int g_init_gtest_count;
+
// The text used in failure messages to indicate the start of the
// stack trace.
extern const char kStackTraceMarker[];
diff --git a/include/gtest/internal/gtest-string.h b/include/gtest/internal/gtest-string.h
index b37ff4f..178f14e 100644
--- a/include/gtest/internal/gtest-string.h
+++ b/include/gtest/internal/gtest-string.h
@@ -44,6 +44,10 @@
#include <string.h>
#include <gtest/internal/gtest-port.h>
+#if GTEST_HAS_GLOBAL_STRING || GTEST_HAS_STD_STRING
+#include <string>
+#endif // GTEST_HAS_GLOBAL_STRING || GTEST_HAS_STD_STRING
+
namespace testing {
namespace internal {
@@ -217,6 +221,24 @@ class String {
// doesn't need to be virtual.
~String() { delete[] c_str_; }
+ // Allows a String to be implicitly converted to an ::std::string or
+ // ::string, and vice versa. Converting a String containing a NULL
+ // pointer to ::std::string or ::string is undefined behavior.
+ // Converting a ::std::string or ::string containing an embedded NUL
+ // character to a String will result in the prefix up to the first
+ // NUL character.
+#if GTEST_HAS_STD_STRING
+ String(const ::std::string& str) : c_str_(NULL) { *this = str.c_str(); }
+
+ operator ::std::string() const { return ::std::string(c_str_); }
+#endif // GTEST_HAS_STD_STRING
+
+#if GTEST_HAS_GLOBAL_STRING
+ String(const ::string& str) : c_str_(NULL) { *this = str.c_str(); }
+
+ operator ::string() const { return ::string(c_str_); }
+#endif // GTEST_HAS_GLOBAL_STRING
+
// Returns true iff this is an empty string (i.e. "").
bool empty() const {
return (c_str_ != NULL) && (*c_str_ == '\0');