ts: re-apply OpenCV-specific patch on googletest 1.8.1

pull/12382/head
Alexander Alekhin 7 years ago
parent f7ccc74e09
commit 3dddf703a9
  1. 170
      modules/ts/include/opencv2/ts/ts_gtest.h
  2. 52
      modules/ts/src/ts_gtest.cpp

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

Loading…
Cancel
Save