summaryrefslogtreecommitdiffstats
path: root/googletest/include/gtest/internal/gtest-internal.h
diff options
context:
space:
mode:
authorGennadiy Civil <misterg@google.com>2018-01-11 16:31:23 (GMT)
committerGennadiy Civil <misterg@google.com>2018-01-11 16:31:23 (GMT)
commit6914ae239499b99ab8b3fcbc7c8b584875e29e1b (patch)
tree47107a3f74573777e2b994f18143483dfb602378 /googletest/include/gtest/internal/gtest-internal.h
parent1d757db65cd12679c2d2213aa3430809b6566ef2 (diff)
downloadgoogletest-6914ae239499b99ab8b3fcbc7c8b584875e29e1b.zip
googletest-6914ae239499b99ab8b3fcbc7c8b584875e29e1b.tar.gz
googletest-6914ae239499b99ab8b3fcbc7c8b584875e29e1b.tar.bz2
Upstream cl 103120214
Diffstat (limited to 'googletest/include/gtest/internal/gtest-internal.h')
-rw-r--r--googletest/include/gtest/internal/gtest-internal.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index 2a6e4da..454fffb 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
-// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
//
// The Google C++ Testing Framework (Google Test)
//
@@ -61,8 +60,8 @@
#include <vector>
#include "gtest/gtest-message.h"
-#include "gtest/internal/gtest-string.h"
#include "gtest/internal/gtest-filepath.h"
+#include "gtest/internal/gtest-string.h"
#include "gtest/internal/gtest-type-util.h"
// Due to C++ preprocessor weirdness, we need double indirection to
@@ -157,7 +156,28 @@ class GTEST_API_ ScopedTrace {
public:
// The c'tor pushes the given source file location and message onto
// a trace stack maintained by Google Test.
- ScopedTrace(const char* file, int line, const Message& message);
+
+ // Template version. Uses Message() to convert the values into strings.
+ // Slow, but flexible.
+ template <typename T>
+ ScopedTrace(const char* file, int line, const T& message) {
+ PushTrace(file, line, (Message() << message).GetString());
+ }
+
+ // Optimize for some known types.
+ ScopedTrace(const char* file, int line, const char* message) {
+ PushTrace(file, line, message ? message : "(null)");
+ }
+
+#if GTEST_HAS_GLOBAL_STRING
+ ScopedTrace(const char* file, int line, const ::string& message) {
+ PushTrace(file, line, message);
+ }
+#endif
+
+ ScopedTrace(const char* file, int line, const std::string& message) {
+ PushTrace(file, line, message);
+ }
// The d'tor pops the info pushed by the c'tor.
//
@@ -166,6 +186,8 @@ class GTEST_API_ ScopedTrace {
~ScopedTrace();
private:
+ void PushTrace(const char* file, int line, std::string message);
+
GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace);
} GTEST_ATTRIBUTE_UNUSED_; // A ScopedTrace object does its job in its
// c'tor and d'tor. Therefore it doesn't