From 9d7455f9844e293dff8b7902f0c2553094f2f976 Mon Sep 17 00:00:00 2001 From: vladlosev Date: Wed, 2 Feb 2011 10:07:04 +0000 Subject: Adds null check for file locations in XML output printer. --- include/gtest/internal/gtest-internal.h | 14 -------------- include/gtest/internal/gtest-port.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/gtest/internal/gtest-internal.h b/include/gtest/internal/gtest-internal.h index 23fcef78..9f890faa 100644 --- a/include/gtest/internal/gtest-internal.h +++ b/include/gtest/internal/gtest-internal.h @@ -536,20 +536,6 @@ GTEST_API_ AssertionResult IsHRESULTFailure(const char* expr, #endif // GTEST_OS_WINDOWS -// Formats a source file path and a line number as they would appear -// in a compiler error message. -inline String FormatFileLocation(const char* file, int line) { - const char* const file_name = file == NULL ? "unknown file" : file; - if (line < 0) { - return String::Format("%s:", file_name); - } -#ifdef _MSC_VER - return String::Format("%s(%d):", file_name, line); -#else - return String::Format("%s:%d:", file_name, line); -#endif // _MSC_VER -} - // Types of SetUpTestCase() and TearDownTestCase() functions. typedef void (*SetUpTestCaseFunc)(); typedef void (*TearDownTestCaseFunc)(); diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h index be2297ed..228c468c 100644 --- a/include/gtest/internal/gtest-port.h +++ b/include/gtest/internal/gtest-port.h @@ -848,6 +848,16 @@ class GTEST_API_ RE { GTEST_DISALLOW_ASSIGN_(RE); }; +// Formats a source file path and a line number as they would appear +// in an error message from the compiler used to compile this code. +GTEST_API_ ::std::string FormatFileLocation(const char* file, int line); + +// Formats a file location for compiler-independent XML output. +// Although this function is not platform dependent, we put it next to +// FormatFileLocation in order to contrast the two functions. +GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(const char* file, + int line); + // Defines logging utilities: // GTEST_LOG_(severity) - logs messages at the specified severity level. The // message itself is streamed into the macro. -- cgit v1.2.3