mirror of
https://github.com/opencv/opencv.git
synced 2025-06-10 19:24:07 +08:00
ts: re-apply OpenCV-specific patch on googletest 1.8.1
This commit is contained in:
parent
f7ccc74e09
commit
3dddf703a9
@ -422,64 +422,119 @@
|
||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
|
||||
|
||||
// Determines the platform on which Google Test is compiled.
|
||||
#define GTEST_OS_CYGWIN 0
|
||||
#define GTEST_OS_SYMBIAN 0
|
||||
#define GTEST_OS_WINDOWS 0
|
||||
#define GTEST_OS_WINDOWS_MOBILE 0
|
||||
#define GTEST_OS_WINDOWS_MINGW 0
|
||||
#define GTEST_OS_WINDOWS_DESKTOP 0
|
||||
#define GTEST_OS_WINDOWS_PHONE 0
|
||||
#define GTEST_OS_WINDOWS_TV_TITLE 0
|
||||
#define GTEST_OS_WINDOWS_RT 0
|
||||
#define GTEST_OS_MAC 0
|
||||
#define GTEST_OS_LINUX 0
|
||||
#define GTEST_OS_LINUX_ANDROID 0
|
||||
#define GTEST_OS_ZOS 0
|
||||
#define GTEST_OS_SOLARIS 0
|
||||
#define GTEST_OS_AIX 0
|
||||
#define GTEST_OS_HPUX 0
|
||||
#define GTEST_OS_NACL 0
|
||||
#define GTEST_OS_OPENBSD 0
|
||||
#define GTEST_OS_QNX 0
|
||||
#define GTEST_OS_IOS 0
|
||||
#define GTEST_OS_IOS_SIMULATOR 0
|
||||
#define GTEST_OS_FREEBSD 0
|
||||
#define GTEST_OS_NETBSD 0
|
||||
#define GTEST_OS_FUCHSIA 0
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
# undef GTEST_OS_CYGWIN
|
||||
# define GTEST_OS_CYGWIN 1
|
||||
#elif defined __SYMBIAN32__
|
||||
# undef GTEST_OS_SYMBIAN
|
||||
# define GTEST_OS_SYMBIAN 1
|
||||
#elif defined _WIN32
|
||||
# undef GTEST_OS_WINDOWS
|
||||
# define GTEST_OS_WINDOWS 1
|
||||
# ifdef _WIN32_WCE
|
||||
# undef GTEST_OS_WINDOWS_MOBILE
|
||||
# define GTEST_OS_WINDOWS_MOBILE 1
|
||||
# elif defined(__MINGW__) || defined(__MINGW32__)
|
||||
# undef GTEST_OS_WINDOWS_MINGW
|
||||
# define GTEST_OS_WINDOWS_MINGW 1
|
||||
# elif defined(WINAPI_FAMILY)
|
||||
# include <winapifamily.h>
|
||||
# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||
# undef GTEST_OS_WINDOWS_DESKTOP
|
||||
# define GTEST_OS_WINDOWS_DESKTOP 1
|
||||
# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
|
||||
# undef GTEST_OS_WINDOWS_PHONE
|
||||
# define GTEST_OS_WINDOWS_PHONE 1
|
||||
# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
|
||||
# undef GTEST_OS_WINDOWS_RT
|
||||
# define GTEST_OS_WINDOWS_RT 1
|
||||
# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE)
|
||||
# undef GTEST_OS_WINDOWS_PHONE
|
||||
# undef GTEST_OS_WINDOWS_TV_TITLE
|
||||
# define GTEST_OS_WINDOWS_PHONE 1
|
||||
# define GTEST_OS_WINDOWS_TV_TITLE 1
|
||||
# else
|
||||
// WINAPI_FAMILY defined but no known partition matched.
|
||||
// Default to desktop.
|
||||
# undef GTEST_OS_WINDOWS_DESKTOP
|
||||
# define GTEST_OS_WINDOWS_DESKTOP 1
|
||||
# endif
|
||||
# else
|
||||
# undef GTEST_OS_WINDOWS_DESKTOP
|
||||
# define GTEST_OS_WINDOWS_DESKTOP 1
|
||||
# endif // _WIN32_WCE
|
||||
#elif defined __APPLE__
|
||||
# undef GTEST_OS_MAC
|
||||
# define GTEST_OS_MAC 1
|
||||
# if TARGET_OS_IPHONE
|
||||
# undef GTEST_OS_IOS
|
||||
# define GTEST_OS_IOS 1
|
||||
# if TARGET_IPHONE_SIMULATOR
|
||||
# undef GTEST_OS_IOS_SIMULATOR
|
||||
# define GTEST_OS_IOS_SIMULATOR 1
|
||||
# endif
|
||||
# endif
|
||||
#elif defined __FreeBSD__
|
||||
# undef GTEST_OS_FREEBSD
|
||||
# define GTEST_OS_FREEBSD 1
|
||||
#elif defined __Fuchsia__
|
||||
# undef GTEST_OS_FUCHSIA
|
||||
# define GTEST_OS_FUCHSIA 1
|
||||
#elif defined __linux__
|
||||
# undef GTEST_OS_LINUX
|
||||
# define GTEST_OS_LINUX 1
|
||||
# if defined __ANDROID__
|
||||
# undef GTEST_OS_LINUX_ANDROID
|
||||
# define GTEST_OS_LINUX_ANDROID 1
|
||||
# endif
|
||||
#elif defined __MVS__
|
||||
# undef GTEST_OS_ZOS
|
||||
# define GTEST_OS_ZOS 1
|
||||
#elif defined(__sun) && defined(__SVR4)
|
||||
# undef GTEST_OS_SOLARIS
|
||||
# define GTEST_OS_SOLARIS 1
|
||||
#elif defined(_AIX)
|
||||
# undef GTEST_OS_AIX
|
||||
# define GTEST_OS_AIX 1
|
||||
#elif defined(__hpux)
|
||||
# undef GTEST_OS_HPUX
|
||||
# define GTEST_OS_HPUX 1
|
||||
#elif defined __native_client__
|
||||
# undef GTEST_OS_NACL
|
||||
# define GTEST_OS_NACL 1
|
||||
#elif defined __NetBSD__
|
||||
# undef GTEST_OS_NETBSD
|
||||
# define GTEST_OS_NETBSD 1
|
||||
#elif defined __OpenBSD__
|
||||
# undef GTEST_OS_OPENBSD
|
||||
# define GTEST_OS_OPENBSD 1
|
||||
#elif defined __QNX__
|
||||
# undef GTEST_OS_QNX
|
||||
# define GTEST_OS_QNX 1
|
||||
#endif // __CYGWIN__
|
||||
|
||||
@ -522,6 +577,13 @@
|
||||
|
||||
#endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
|
||||
|
||||
#ifndef GTEST_HAS_NOTIFICATION_
|
||||
#define GTEST_HAS_NOTIFICATION_ 0
|
||||
#endif
|
||||
#ifndef GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
|
||||
#define GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ 0
|
||||
#endif
|
||||
|
||||
#if !defined(GTEST_DEV_EMAIL_)
|
||||
# define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com"
|
||||
# define GTEST_FLAG_PREFIX_ "gtest_"
|
||||
@ -547,7 +609,7 @@
|
||||
// GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385)
|
||||
// /* code that triggers warnings C4800 and C4385 */
|
||||
// GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||
#if _MSC_VER >= 1400
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \
|
||||
__pragma(warning(push)) \
|
||||
__pragma(warning(disable: warnings))
|
||||
@ -580,7 +642,7 @@
|
||||
// -std={c,gnu}++{0x,11} is passed. The C++11 standard specifies a
|
||||
// value for __cplusplus, and recent versions of clang, gcc, and
|
||||
// probably other compilers set that too in C++11 mode.
|
||||
# if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L || _MSC_VER >= 1900
|
||||
# if defined __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900)
|
||||
// Compiling in at least C++11 mode.
|
||||
# define GTEST_LANG_CXX11 1
|
||||
# else
|
||||
@ -606,6 +668,8 @@
|
||||
__GLIBCXX__ != 20110428ul && /* GCC 4.5.3 */ \
|
||||
__GLIBCXX__ != 20120702ul)) /* GCC 4.5.4 */
|
||||
# define GTEST_STDLIB_CXX11 1
|
||||
#else
|
||||
# define GTEST_STDLIB_CXX11 0
|
||||
#endif
|
||||
|
||||
// Only use C++11 library features if the library provides them.
|
||||
@ -622,6 +686,18 @@
|
||||
# define GTEST_HAS_STD_SHARED_PTR_ 1
|
||||
# define GTEST_HAS_UNORDERED_MAP_ 1
|
||||
# define GTEST_HAS_UNORDERED_SET_ 1
|
||||
#else
|
||||
# define GTEST_HAS_STD_BEGIN_AND_END_ 0
|
||||
# define GTEST_HAS_STD_FORWARD_LIST_ 0
|
||||
# define GTEST_HAS_STD_FUNCTION_ 0
|
||||
# define GTEST_HAS_STD_INITIALIZER_LIST_ 0
|
||||
# define GTEST_HAS_STD_MOVE_ 0
|
||||
# define GTEST_HAS_STD_SHARED_PTR_ 0
|
||||
# define GTEST_HAS_STD_TYPE_TRAITS_ 0
|
||||
# define GTEST_HAS_STD_UNIQUE_PTR_ 0
|
||||
# define GTEST_HAS_STD_SHARED_PTR_ 0
|
||||
# define GTEST_HAS_UNORDERED_MAP_ 0
|
||||
# define GTEST_HAS_UNORDERED_SET_ 0
|
||||
#endif
|
||||
|
||||
// C++11 specifies that <tuple> provides std::tuple.
|
||||
@ -647,6 +723,8 @@
|
||||
# undef GTEST_HAS_STD_TUPLE_
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
# define GTEST_HAS_STD_TUPLE_ 0
|
||||
#endif
|
||||
|
||||
// Brings in definitions for functions used in the testing::internal::posix
|
||||
@ -691,6 +769,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef GTEST_USES_PCRE
|
||||
#define GTEST_USES_PCRE 0
|
||||
#endif
|
||||
|
||||
#if GTEST_USES_PCRE
|
||||
// The appropriate headers have already been included.
|
||||
|
||||
@ -703,18 +785,21 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
# include <regex.h> // NOLINT
|
||||
|
||||
# define GTEST_USES_POSIX_RE 1
|
||||
# define GTEST_USES_SIMPLE_RE 0
|
||||
|
||||
#elif GTEST_OS_WINDOWS
|
||||
|
||||
// <regex.h> is not available on Windows. Use our own simple regex
|
||||
// implementation instead.
|
||||
# define GTEST_USES_SIMPLE_RE 1
|
||||
# define GTEST_USES_POSIX_RE 0
|
||||
|
||||
#else
|
||||
|
||||
// <regex.h> may not be available on this platform. Use our own
|
||||
// simple regex implementation instead.
|
||||
# define GTEST_USES_SIMPLE_RE 1
|
||||
# define GTEST_USES_POSIX_RE 0
|
||||
|
||||
#endif // GTEST_USES_PCRE
|
||||
|
||||
@ -907,7 +992,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
# define GTEST_HAS_TR1_TUPLE 0
|
||||
# else
|
||||
// The user didn't tell us not to do it, so we assume it's OK.
|
||||
# define GTEST_HAS_TR1_TUPLE 1
|
||||
# define GTEST_HAS_TR1_TUPLE 1
|
||||
# endif
|
||||
#endif // GTEST_HAS_TR1_TUPLE
|
||||
|
||||
@ -932,8 +1017,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
// and it can be used with some compilers that define __GNUC__.
|
||||
# if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000) \
|
||||
&& !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) \
|
||||
|| (_MSC_VER >= 1600 && _MSC_VER < 1900)
|
||||
|| (defined(_MSC_VER) && _MSC_VER >= 1600 && _MSC_VER < 1900)
|
||||
# define GTEST_ENV_HAS_TR1_TUPLE_ 1
|
||||
# else
|
||||
# define GTEST_ENV_HAS_TR1_TUPLE_ 0
|
||||
# endif
|
||||
|
||||
// C++11 specifies that <tuple> provides std::tuple. Use that if gtest is used
|
||||
@ -941,12 +1028,16 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
// can build with clang but need to use gcc4.2's libstdc++).
|
||||
# if GTEST_LANG_CXX11 && (!defined(__GLIBCXX__) || __GLIBCXX__ > 20110325)
|
||||
# define GTEST_ENV_HAS_STD_TUPLE_ 1
|
||||
# else
|
||||
# define GTEST_ENV_HAS_STD_TUPLE_ 0
|
||||
# endif
|
||||
|
||||
# if GTEST_ENV_HAS_TR1_TUPLE_ || GTEST_ENV_HAS_STD_TUPLE_
|
||||
# define GTEST_USE_OWN_TR1_TUPLE 0
|
||||
# else
|
||||
# define GTEST_USE_OWN_TR1_TUPLE 1
|
||||
# undef GTEST_HAS_TR1_TUPLE
|
||||
# define GTEST_HAS_TR1_TUPLE 1
|
||||
# endif
|
||||
# endif // GTEST_OS_SYMBIAN
|
||||
#endif // GTEST_USE_OWN_TR1_TUPLE
|
||||
@ -2022,7 +2113,7 @@ inline bool operator!=(const GTEST_10_TUPLE_(T)& t,
|
||||
# endif // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
|
||||
|
||||
// VS 2010 now has tr1 support.
|
||||
# elif _MSC_VER >= 1600
|
||||
# elif defined(_MSC_VER) && _MSC_VER >= 1600
|
||||
# include <tuple> // IWYU pragma: export // NOLINT
|
||||
|
||||
# else // GTEST_USE_OWN_TR1_TUPLE
|
||||
@ -2083,6 +2174,9 @@ inline bool operator!=(const GTEST_10_TUPLE_(T)& t,
|
||||
GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD || \
|
||||
GTEST_OS_NETBSD || GTEST_OS_FUCHSIA)
|
||||
# define GTEST_HAS_DEATH_TEST 1
|
||||
# include <vector> // NOLINT
|
||||
#else
|
||||
# define GTEST_HAS_DEATH_TEST 0
|
||||
#endif
|
||||
|
||||
// Determines whether to support type-driven tests.
|
||||
@ -2110,6 +2204,8 @@ inline bool operator!=(const GTEST_10_TUPLE_(T)& t,
|
||||
// Determines whether test results can be streamed to a socket.
|
||||
#if GTEST_OS_LINUX
|
||||
# define GTEST_CAN_STREAM_RESULTS_ 1
|
||||
#else
|
||||
# define GTEST_CAN_STREAM_RESULTS_ 0
|
||||
#endif
|
||||
|
||||
// Defines some utility macros.
|
||||
@ -2440,6 +2536,9 @@ typedef ::std::wstring wstring;
|
||||
// returns 'condition'.
|
||||
GTEST_API_ bool IsTrue(bool condition);
|
||||
|
||||
template <typename T> class scoped_ptr;
|
||||
template <typename T> static void swap(scoped_ptr<T>& a, scoped_ptr<T>& b);
|
||||
|
||||
// Defines scoped_ptr.
|
||||
|
||||
// This implementation of scoped_ptr is PARTIAL - it only contains
|
||||
@ -2471,10 +2570,7 @@ class scoped_ptr {
|
||||
}
|
||||
}
|
||||
|
||||
friend void swap(scoped_ptr& a, scoped_ptr& b) {
|
||||
using std::swap;
|
||||
swap(a.ptr_, b.ptr_);
|
||||
}
|
||||
friend void swap<T>(scoped_ptr<T>& a, scoped_ptr<T>& b);
|
||||
|
||||
private:
|
||||
T* ptr_;
|
||||
@ -2482,6 +2578,12 @@ class scoped_ptr {
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(scoped_ptr);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
static void swap(scoped_ptr<T>& a, scoped_ptr<T>& b) {
|
||||
using std::swap;
|
||||
swap(a.ptr_, b.ptr_);
|
||||
}
|
||||
|
||||
// Defines RE.
|
||||
|
||||
#if GTEST_USES_PCRE
|
||||
@ -2621,7 +2723,7 @@ inline void FlushInfoLog() { fflush(NULL); }
|
||||
//
|
||||
// GTEST_CHECK_ is an all-mode assert. It aborts the program if the condition
|
||||
// is not satisfied.
|
||||
// Synopsys:
|
||||
// Synopsis:
|
||||
// GTEST_CHECK_(boolean_condition);
|
||||
// or
|
||||
// GTEST_CHECK_(boolean_condition) << "Additional message";
|
||||
@ -2711,7 +2813,7 @@ struct RvalueRef {
|
||||
// const Foo*). When you use ImplicitCast_, the compiler checks that
|
||||
// the cast is safe. Such explicit ImplicitCast_s are necessary in
|
||||
// surprisingly many situations where C++ demands an exact type match
|
||||
// instead of an argument type convertable to a target type.
|
||||
// instead of an argument type convertible to a target type.
|
||||
//
|
||||
// The syntax for using ImplicitCast_ is the same as for static_cast:
|
||||
//
|
||||
@ -2779,7 +2881,7 @@ Derived* CheckedDowncastToActualType(Base* base) {
|
||||
GTEST_CHECK_(typeid(*base) == typeid(Derived));
|
||||
#endif
|
||||
|
||||
#if GTEST_HAS_DOWNCAST_
|
||||
#if defined(GTEST_HAS_DOWNCAST_) && GTEST_HAS_DOWNCAST_
|
||||
return ::down_cast<Derived*>(base);
|
||||
#elif GTEST_HAS_RTTI
|
||||
return dynamic_cast<Derived*>(base); // NOLINT
|
||||
@ -3816,7 +3918,7 @@ inline void Abort() { abort(); }
|
||||
// MSVC-based platforms. We map the GTEST_SNPRINTF_ macro to the appropriate
|
||||
// function in order to achieve that. We use macro definition here because
|
||||
// snprintf is a variadic function.
|
||||
#if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE
|
||||
// MSVC 2005 and above support variadic macros.
|
||||
# define GTEST_SNPRINTF_(buffer, size, format, ...) \
|
||||
_snprintf_s(buffer, size, size, format, __VA_ARGS__)
|
||||
@ -4590,7 +4692,7 @@ class GTEST_API_ FilePath {
|
||||
|
||||
void Normalize();
|
||||
|
||||
// Returns a pointer to the last occurence of a valid path separator in
|
||||
// Returns a pointer to the last occurrence of a valid path separator in
|
||||
// the FilePath. On Windows, for example, both '/' and '\' are valid path
|
||||
// separators. Returns NULL if no path separator was found.
|
||||
const char* FindLastPathSeparator() const;
|
||||
@ -9162,7 +9264,7 @@ class NativeArray {
|
||||
|
||||
// Implements Boolean test assertions such as EXPECT_TRUE. expression can be
|
||||
// either a boolean expression or an AssertionResult. text is a textual
|
||||
// represenation of expression as it was passed into the EXPECT_TRUE.
|
||||
// representation of expression as it was passed into the EXPECT_TRUE.
|
||||
#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (const ::testing::AssertionResult gtest_ar_ = \
|
||||
@ -10420,6 +10522,10 @@ linked_ptr<T> make_linked_ptr(T* ptr) {
|
||||
# include <tuple>
|
||||
#endif
|
||||
|
||||
#ifndef GTEST_HAS_ABSL
|
||||
#define GTEST_HAS_ABSL 0
|
||||
#endif
|
||||
|
||||
#if GTEST_HAS_ABSL
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/types/optional.h"
|
||||
@ -10494,7 +10600,7 @@ class TypeWithoutFormatter<T, kConvertibleToInteger> {
|
||||
// T is not an enum, printing it as an integer is the best we can do
|
||||
// given that it has no user-defined printer.
|
||||
static void PrintValue(const T& value, ::std::ostream* os) {
|
||||
const internal::BiggestInt kBigInt = value;
|
||||
const internal::BiggestInt kBigInt = static_cast<internal::BiggestInt>(value);
|
||||
*os << kBigInt;
|
||||
}
|
||||
};
|
||||
@ -11804,12 +11910,15 @@ typename ParamNameGenFunc<ParamType>::Type *GetParamNameGen() {
|
||||
return DefaultParamName;
|
||||
}
|
||||
|
||||
} // namespace internal:: // fixes MacOS X issue with "friend class internal/*::anon*/::ParameterizedTestFactory;"
|
||||
namespace { // wrap into anynomous namespace to avoid build warnings like GCC's -Wsubobject-linkage
|
||||
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
|
||||
//
|
||||
// Stores a parameter value and later creates tests parameterized with that
|
||||
// value.
|
||||
template <class TestClass>
|
||||
class ParameterizedTestFactory : public TestFactoryBase {
|
||||
class ParameterizedTestFactory : public internal::TestFactoryBase {
|
||||
public:
|
||||
typedef typename TestClass::ParamType ParamType;
|
||||
explicit ParameterizedTestFactory(ParamType parameter) :
|
||||
@ -11824,6 +11933,8 @@ class ParameterizedTestFactory : public TestFactoryBase {
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory);
|
||||
};
|
||||
} // namespace
|
||||
namespace internal {
|
||||
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
|
||||
//
|
||||
@ -19526,6 +19637,9 @@ GTEST_DECLARE_string_(filter);
|
||||
// debugging information when fatal signals are raised.
|
||||
GTEST_DECLARE_bool_(install_failure_signal_handler);
|
||||
|
||||
// OpenCV extension: same as filter, but for the parameters string.
|
||||
GTEST_DECLARE_string_(param_filter);
|
||||
|
||||
// This flag causes the Google Test to list tests. None of the tests listed
|
||||
// are actually run if the flag is provided.
|
||||
GTEST_DECLARE_bool_(list_tests);
|
||||
@ -21520,6 +21634,11 @@ class GTEST_API_ AssertHelper {
|
||||
|
||||
} // namespace internal
|
||||
|
||||
namespace internal {
|
||||
// Static value used for accessing test parameter during a test lifetime.
|
||||
extern void* g_parameter_;
|
||||
} // namespace internal
|
||||
|
||||
// The pure interface class that all value-parameterized tests inherit from.
|
||||
// A value-parameterized class must inherit from both ::testing::Test and
|
||||
// ::testing::WithParamInterface. In most cases that just means inheriting
|
||||
@ -21566,29 +21685,28 @@ class WithParamInterface {
|
||||
// like writing 'WithParamInterface<bool>::GetParam()' for a test that
|
||||
// uses a fixture whose parameter type is int.
|
||||
const ParamType& GetParam() const {
|
||||
GTEST_CHECK_(parameter_ != NULL)
|
||||
GTEST_CHECK_(GetParameterPtrRef_() != NULL)
|
||||
<< "GetParam() can only be called inside a value-parameterized test "
|
||||
<< "-- did you intend to write TEST_P instead of TEST_F?";
|
||||
return *parameter_;
|
||||
return *GetParameterPtrRef_();
|
||||
}
|
||||
|
||||
private:
|
||||
// Sets parameter value. The caller is responsible for making sure the value
|
||||
// remains alive and unchanged throughout the current test.
|
||||
static void SetParam(const ParamType* parameter) {
|
||||
parameter_ = parameter;
|
||||
GetParameterPtrRef_() = parameter;
|
||||
}
|
||||
|
||||
// Static value used for accessing parameter during a test lifetime.
|
||||
static const ParamType* parameter_;
|
||||
static const ParamType*& GetParameterPtrRef_()
|
||||
{
|
||||
return (const ParamType*&)internal::g_parameter_;
|
||||
}
|
||||
|
||||
// TestClass must be a subclass of WithParamInterface<T> and Test.
|
||||
template <class TestClass> friend class internal::ParameterizedTestFactory;
|
||||
template <class TestClass> friend class /*internal::*/ParameterizedTestFactory;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
const T* WithParamInterface<T>::parameter_ = NULL;
|
||||
|
||||
// Most value-parameterized classes can ignore the existence of
|
||||
// WithParamInterface, and can just inherit from ::testing::TestWithParam.
|
||||
|
||||
|
@ -35,7 +35,15 @@
|
||||
|
||||
// This line ensures that gtest.h can be compiled on its own, even
|
||||
// when it's fused.
|
||||
#include "gtest/gtest.h"
|
||||
#include "precomp.hpp"
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
# if __GNUC__ >= 5
|
||||
# pragma GCC diagnostic ignored "-Wsuggest-override"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// The following lines pull in the real gtest *.cc files.
|
||||
// Copyright 2005, Google Inc.
|
||||
@ -487,6 +495,7 @@ const char kBreakOnFailureFlag[] = "break_on_failure";
|
||||
const char kCatchExceptionsFlag[] = "catch_exceptions";
|
||||
const char kColorFlag[] = "color";
|
||||
const char kFilterFlag[] = "filter";
|
||||
const char kParamFilterFlag[] = "param_filter";
|
||||
const char kListTestsFlag[] = "list_tests";
|
||||
const char kOutputFlag[] = "output";
|
||||
const char kPrintTimeFlag[] = "print_time";
|
||||
@ -567,6 +576,7 @@ class GTestFlagSaver {
|
||||
death_test_style_ = GTEST_FLAG(death_test_style);
|
||||
death_test_use_fork_ = GTEST_FLAG(death_test_use_fork);
|
||||
filter_ = GTEST_FLAG(filter);
|
||||
param_filter_ = GTEST_FLAG(param_filter);
|
||||
internal_run_death_test_ = GTEST_FLAG(internal_run_death_test);
|
||||
list_tests_ = GTEST_FLAG(list_tests);
|
||||
output_ = GTEST_FLAG(output);
|
||||
@ -589,6 +599,7 @@ class GTestFlagSaver {
|
||||
GTEST_FLAG(death_test_style) = death_test_style_;
|
||||
GTEST_FLAG(death_test_use_fork) = death_test_use_fork_;
|
||||
GTEST_FLAG(filter) = filter_;
|
||||
GTEST_FLAG(param_filter) = param_filter_;
|
||||
GTEST_FLAG(internal_run_death_test) = internal_run_death_test_;
|
||||
GTEST_FLAG(list_tests) = list_tests_;
|
||||
GTEST_FLAG(output) = output_;
|
||||
@ -611,6 +622,7 @@ class GTestFlagSaver {
|
||||
std::string death_test_style_;
|
||||
bool death_test_use_fork_;
|
||||
std::string filter_;
|
||||
std::string param_filter_;
|
||||
std::string internal_run_death_test_;
|
||||
bool list_tests_;
|
||||
std::string output_;
|
||||
@ -1718,6 +1730,12 @@ GTEST_DEFINE_bool_(
|
||||
"install a signal handler that dumps debugging information when fatal "
|
||||
"signals are raised.");
|
||||
|
||||
GTEST_DEFINE_string_(
|
||||
param_filter,
|
||||
internal::StringFromGTestEnv("param_filter", GetDefaultFilter()),
|
||||
"Same syntax and semantics as for param, but these patterns "
|
||||
"have to match the test's parameters.");
|
||||
|
||||
GTEST_DEFINE_bool_(list_tests, false,
|
||||
"List all tests without running them.");
|
||||
|
||||
@ -4592,6 +4610,14 @@ void PrettyUnitTestResultPrinter::OnTestIterationStart(
|
||||
"Note: %s filter = %s\n", GTEST_NAME_, filter);
|
||||
}
|
||||
|
||||
const char* const param_filter = GTEST_FLAG(param_filter).c_str();
|
||||
|
||||
// Ditto.
|
||||
if (!String::CStringEquals(param_filter, kUniversalFilter)) {
|
||||
ColoredPrintf(COLOR_YELLOW,
|
||||
"Note: %s parameter filter = %s\n", GTEST_NAME_, param_filter);
|
||||
}
|
||||
|
||||
if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) {
|
||||
const Int32 shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);
|
||||
ColoredPrintf(COLOR_YELLOW,
|
||||
@ -4636,6 +4662,7 @@ void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) {
|
||||
void PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) {
|
||||
ColoredPrintf(COLOR_GREEN, "[ RUN ] ");
|
||||
PrintTestName(test_info.test_case_name(), test_info.name());
|
||||
PrintFullTestCommentIfPresent(test_info);
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
@ -5961,13 +5988,13 @@ UnitTest* UnitTest::GetInstance() {
|
||||
// default implementation. Use this implementation to keep good OO
|
||||
// design with private destructor.
|
||||
|
||||
#if (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
|
||||
#if (defined(_MSC_VER) && _MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
|
||||
static UnitTest* const instance = new UnitTest;
|
||||
return instance;
|
||||
#else
|
||||
static UnitTest instance;
|
||||
return &instance;
|
||||
#endif // (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
|
||||
#endif // (defined(_MSC_VER) && _MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
|
||||
}
|
||||
|
||||
// Gets the number of successful test cases.
|
||||
@ -6813,9 +6840,15 @@ int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
|
||||
kDisableTestFilter);
|
||||
test_info->is_disabled_ = is_disabled;
|
||||
|
||||
const std::string value_param(test_info->value_param() == NULL ?
|
||||
"" : test_info->value_param());
|
||||
|
||||
const bool matches_filter =
|
||||
internal::UnitTestOptions::FilterMatchesTest(test_case_name,
|
||||
test_name);
|
||||
test_name) &&
|
||||
internal::UnitTestOptions::MatchesFilter(value_param,
|
||||
GTEST_FLAG(param_filter).c_str());
|
||||
|
||||
test_info->matches_filter_ = matches_filter;
|
||||
|
||||
const bool is_runnable =
|
||||
@ -7189,6 +7222,12 @@ static const char kColorEncodedHelpMessage[] =
|
||||
" Run only the tests whose name matches one of the positive patterns but\n"
|
||||
" none of the negative patterns. '?' matches any single character; '*'\n"
|
||||
" matches any substring; ':' separates two patterns.\n"
|
||||
" @G--" GTEST_FLAG_PREFIX_ "param_filter=@YPOSITIVE_PATTERNS"
|
||||
"[@G-@YNEGATIVE_PATTERNS]@D\n"
|
||||
" Like @G--" GTEST_FLAG_PREFIX_
|
||||
"filter@D, but applies to the test's parameter. If a\n"
|
||||
" test is not parameterized, its parameter is considered to be the\n"
|
||||
" empty string.\n"
|
||||
" @G--" GTEST_FLAG_PREFIX_ "also_run_disabled_tests@D\n"
|
||||
" Run all disabled tests too.\n"
|
||||
"\n"
|
||||
@ -7254,6 +7293,7 @@ static bool ParseGoogleTestFlag(const char* const arg) {
|
||||
ParseBoolFlag(arg, kDeathTestUseFork,
|
||||
>EST_FLAG(death_test_use_fork)) ||
|
||||
ParseStringFlag(arg, kFilterFlag, >EST_FLAG(filter)) ||
|
||||
ParseStringFlag(arg, kParamFilterFlag, >EST_FLAG(param_filter)) ||
|
||||
ParseStringFlag(arg, kInternalRunDeathTestFlag,
|
||||
>EST_FLAG(internal_run_death_test)) ||
|
||||
ParseBoolFlag(arg, kListTestsFlag, >EST_FLAG(list_tests)) ||
|
||||
@ -9096,6 +9136,7 @@ namespace internal {
|
||||
// of them.
|
||||
const char kPathSeparator = '\\';
|
||||
const char kAlternatePathSeparator = '/';
|
||||
//const char kPathSeparatorString[] = "\\";
|
||||
const char kAlternatePathSeparatorString[] = "/";
|
||||
# if GTEST_OS_WINDOWS_MOBILE
|
||||
// Windows CE doesn't have a current directory. You should not use
|
||||
@ -9109,6 +9150,7 @@ const char kCurrentDirectoryString[] = ".\\";
|
||||
# endif // GTEST_OS_WINDOWS_MOBILE
|
||||
#else
|
||||
const char kPathSeparator = '/';
|
||||
//const char kPathSeparatorString[] = "/";
|
||||
const char kCurrentDirectoryString[] = "./";
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
|
||||
@ -11390,5 +11432,7 @@ const char* TypedTestCasePState::VerifyRegisteredTestNames(
|
||||
|
||||
#endif // GTEST_HAS_TYPED_TEST_P
|
||||
|
||||
void* g_parameter_ = NULL;
|
||||
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
|
Loading…
Reference in New Issue
Block a user