Merge branch 'master' into win-libcxx
This commit is contained in:
@@ -1299,9 +1299,9 @@ class GTEST_API_ UnitTest {
|
||||
|
||||
// These classes and functions are friends as they need to access private
|
||||
// members of UnitTest.
|
||||
friend class ScopedTrace;
|
||||
friend class Test;
|
||||
friend class internal::AssertHelper;
|
||||
friend class internal::ScopedTrace;
|
||||
friend class internal::StreamingListenerTest;
|
||||
friend class internal::UnitTestRecordPropertyTestHelper;
|
||||
friend Environment* AddGlobalTestEnvironment(Environment* env);
|
||||
@@ -2102,6 +2102,57 @@ GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
|
||||
#define EXPECT_NO_FATAL_FAILURE(statement) \
|
||||
GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)
|
||||
|
||||
// Causes a trace (including the given source file path and line number,
|
||||
// and the given message) to be included in every test failure message generated
|
||||
// by code in the scope of the lifetime of an instance of this class. The effect
|
||||
// is undone with the destruction of the instance.
|
||||
//
|
||||
// The message argument can be anything streamable to std::ostream.
|
||||
//
|
||||
// Example:
|
||||
// testing::ScopedTrace trace("file.cc", 123, "message");
|
||||
//
|
||||
class GTEST_API_ ScopedTrace {
|
||||
public:
|
||||
// The c'tor pushes the given source file location and message onto
|
||||
// a trace stack maintained by Google Test.
|
||||
|
||||
// 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.
|
||||
//
|
||||
// Note that the d'tor is not virtual in order to be efficient.
|
||||
// Don't inherit from 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
|
||||
// need to be used otherwise.
|
||||
|
||||
// Causes a trace (including the source file path, the current line
|
||||
// number, and the given message) to be included in every test failure
|
||||
// message generated by code in the current scope. The effect is
|
||||
@@ -2118,7 +2169,7 @@ GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
|
||||
// Therefore, a SCOPED_TRACE() would (correctly) only affect the
|
||||
// assertions in its own thread.
|
||||
#define SCOPED_TRACE(message) \
|
||||
::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
|
||||
::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
|
||||
__FILE__, __LINE__, (message))
|
||||
|
||||
|
||||
|
||||
@@ -95,7 +95,6 @@ template <typename T>
|
||||
namespace internal {
|
||||
|
||||
struct TraceInfo; // Information about a trace point.
|
||||
class ScopedTrace; // Implements scoped trace.
|
||||
class TestInfoImpl; // Opaque implementation of TestInfo
|
||||
class UnitTestImpl; // Opaque implementation of UnitTest
|
||||
|
||||
@@ -151,48 +150,6 @@ class GTEST_API_ GoogleTestFailureException : public ::std::runtime_error {
|
||||
|
||||
#endif // GTEST_HAS_EXCEPTIONS
|
||||
|
||||
// A helper class for creating scoped traces in user programs.
|
||||
class GTEST_API_ ScopedTrace {
|
||||
public:
|
||||
// The c'tor pushes the given source file location and message onto
|
||||
// a trace stack maintained by Google Test.
|
||||
|
||||
// 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.
|
||||
//
|
||||
// Note that the d'tor is not virtual in order to be efficient.
|
||||
// Don't inherit from 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
|
||||
// need to be used otherwise.
|
||||
|
||||
namespace edit_distance {
|
||||
// Returns the optimal edits to go from 'left' to 'right'.
|
||||
// All edits cost the same, with replace having lower priority than
|
||||
|
||||
Reference in New Issue
Block a user