diff --git a/modules/ts/include/opencv2/ts/ts_gtest.h b/modules/ts/include/opencv2/ts/ts_gtest.h index b687a5722e..c04205d017 100644 --- a/modules/ts/include/opencv2/ts/ts_gtest.h +++ b/modules/ts/include/opencv2/ts/ts_gtest.h @@ -412,105 +412,57 @@ #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_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 - #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 # 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 # 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 __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 __OpenBSD__ -# undef GTEST_OS_OPENBSD # define GTEST_OS_OPENBSD 1 #elif defined __QNX__ -# undef GTEST_OS_QNX # define GTEST_OS_QNX 1 #endif // __CYGWIN__ @@ -585,13 +537,6 @@ #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_" @@ -617,7 +562,7 @@ // GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385) // /* code that triggers warnings C4800 and C4385 */ // GTEST_DISABLE_MSC_WARNINGS_POP_() -#if defined(_MSC_VER) && _MSC_VER >= 1500 +#if _MSC_VER >= 1500 # define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \ __pragma(warning(push)) \ __pragma(warning(disable: warnings)) @@ -634,7 +579,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 defined __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L +# if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L // Compiling in at least C++11 mode. # define GTEST_LANG_CXX11 1 # else @@ -660,8 +605,6 @@ __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. @@ -674,15 +617,6 @@ # define GTEST_HAS_STD_SHARED_PTR_ 1 # define GTEST_HAS_STD_TYPE_TRAITS_ 1 # define GTEST_HAS_STD_UNIQUE_PTR_ 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 #endif // C++11 specifies that provides std::tuple. @@ -707,8 +641,6 @@ # 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 @@ -720,16 +652,10 @@ # include # endif // In order to avoid having to include , use forward declaration -#if GTEST_OS_WINDOWS_MINGW && !defined(__MINGW64_VERSION_MAJOR) - // MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two - // separate (equivalent) structs, instead of using typedef - typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION; -# else - // assuming CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION. - // This assumption is verified by - // WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION. - typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; -# endif +// assuming CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION. +// This assumption is verified by +// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION. +struct _RTL_CRITICAL_SECTION; #else // This assumes that non-Windows OSes provide unistd.h. For OSes where this // is not the case, we need to include headers that provide the functions @@ -746,14 +672,14 @@ // Defines this to true iff Google Test can use POSIX regular expressions. #ifndef GTEST_HAS_POSIX_RE # if GTEST_OS_LINUX_ANDROID -// On Android, is only available starting with Froyo. -# define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 8) +// On Android, is only available starting with Gingerbread. +# define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9) # else -# define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS) -#endif +# define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS) +# endif #endif -#if defined(GTEST_USES_PCRE) && GTEST_USES_PCRE +#if GTEST_USES_PCRE // The appropriate headers have already been included. #elif GTEST_HAS_POSIX_RE @@ -765,21 +691,18 @@ # include // NOLINT # define GTEST_USES_POSIX_RE 1 -# define GTEST_USES_SIMPLE_RE 0 #elif GTEST_OS_WINDOWS // 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 // 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 @@ -888,8 +811,8 @@ !defined(__EXCEPTIONS) # define GTEST_HAS_RTTI 0 # else -# define GTEST_HAS_RTTI 1 -# endif // GTEST_OS_LINUX_ANDROID && _STLPORT_MAJOR && !__EXCEPTIONS +# define GTEST_HAS_RTTI 1 +# endif // GTEST_OS_LINUX_ANDROID && __STLPORT_MAJOR && !__EXCEPTIONS # else # define GTEST_HAS_RTTI 0 # endif // __GXX_RTTI @@ -949,7 +872,7 @@ // Determines if hash_map/hash_set are available. // Only used for testing against those containers. #if !defined(GTEST_HAS_HASH_MAP_) -# ifdef _MSC_VER +# if _MSC_VER # define GTEST_HAS_HASH_MAP_ 1 // Indicates that hash_map is available. # define GTEST_HAS_HASH_SET_ 1 // Indicates that hash_set is available. # endif // _MSC_VER @@ -964,7 +887,7 @@ # 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 @@ -984,11 +907,8 @@ // support TR1 tuple. libc++ only provides std::tuple, in C++11 mode, // 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)) && !defined(_STLPORT_MAJOR) \ - || (defined(_MSC_VER) && _MSC_VER >= 1600) + && !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) || _MSC_VER >= 1600 # define GTEST_ENV_HAS_TR1_TUPLE_ 1 -# else -# define GTEST_ENV_HAS_TR1_TUPLE_ 0 # endif // C++11 specifies that provides std::tuple. Use that if gtest is used @@ -996,16 +916,12 @@ // 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_USE_OWN_TR1_TUPLE @@ -1178,52 +1094,52 @@ template struct TupleElement; template -struct TupleElement { +struct TupleElement { typedef T0 type; }; template -struct TupleElement { +struct TupleElement { typedef T1 type; }; template -struct TupleElement { +struct TupleElement { typedef T2 type; }; template -struct TupleElement { +struct TupleElement { typedef T3 type; }; template -struct TupleElement { +struct TupleElement { typedef T4 type; }; template -struct TupleElement { +struct TupleElement { typedef T5 type; }; template -struct TupleElement { +struct TupleElement { typedef T6 type; }; template -struct TupleElement { +struct TupleElement { typedef T7 type; }; template -struct TupleElement { +struct TupleElement { typedef T8 type; }; template -struct TupleElement { +struct TupleElement { typedef T9 type; }; @@ -1766,57 +1682,57 @@ inline GTEST_10_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2, template struct tuple_size; template -struct tuple_size { +struct tuple_size { static const int value = 0; }; template -struct tuple_size { +struct tuple_size { static const int value = 1; }; template -struct tuple_size { +struct tuple_size { static const int value = 2; }; template -struct tuple_size { +struct tuple_size { static const int value = 3; }; template -struct tuple_size { +struct tuple_size { static const int value = 4; }; template -struct tuple_size { +struct tuple_size { static const int value = 5; }; template -struct tuple_size { +struct tuple_size { static const int value = 6; }; template -struct tuple_size { +struct tuple_size { static const int value = 7; }; template -struct tuple_size { +struct tuple_size { static const int value = 8; }; template -struct tuple_size { +struct tuple_size { static const int value = 9; }; template -struct tuple_size { +struct tuple_size { static const int value = 10; }; @@ -2002,8 +1918,8 @@ template inline bool operator==(const GTEST_10_TUPLE_(T)& t, const GTEST_10_TUPLE_(U)& u) { return gtest_internal::SameSizeTuplePrefixComparator< - tuple_size::value, - tuple_size::value>::Eq(t, u); + tuple_size::value, + tuple_size::value>::Eq(t, u); } template @@ -2114,13 +2030,13 @@ using ::std::tuple_size; # if GTEST_OS_LINUX && !defined(__ia64__) # if GTEST_OS_LINUX_ANDROID // On Android, clone() is only available on ARM starting with Gingerbread. -# if (defined(__arm__) || defined(__mips__)) && __ANDROID_API__ >= 9 +# if defined(__arm__) && __ANDROID_API__ >= 9 # define GTEST_HAS_CLONE 1 # else # define GTEST_HAS_CLONE 0 # endif # else -# define GTEST_HAS_CLONE 1 +# define GTEST_HAS_CLONE 1 # endif # else # define GTEST_HAS_CLONE 0 @@ -2151,9 +2067,6 @@ using ::std::tuple_size; GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \ GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD) # define GTEST_HAS_DEATH_TEST 1 -# include // NOLINT -#else -# define GTEST_HAS_DEATH_TEST 0 #endif // We don't support MSVC 7.1 with exceptions disabled now. Therefore @@ -2186,8 +2099,6 @@ using ::std::tuple_size; // 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. @@ -2471,9 +2382,6 @@ typedef ::std::wstring wstring; // returns 'condition'. GTEST_API_ bool IsTrue(bool condition); -template class scoped_ptr; -template static void swap(scoped_ptr& a, scoped_ptr& b); - // Defines scoped_ptr. // This implementation of scoped_ptr is PARTIAL - it only contains @@ -2505,7 +2413,10 @@ class scoped_ptr { } } - friend void swap(scoped_ptr& a, scoped_ptr& b); + friend void swap(scoped_ptr& a, scoped_ptr& b) { + using std::swap; + swap(a.ptr_, b.ptr_); + } private: T* ptr_; @@ -2513,12 +2424,6 @@ class scoped_ptr { GTEST_DISALLOW_COPY_AND_ASSIGN_(scoped_ptr); }; -template -static void swap(scoped_ptr& a, scoped_ptr& b) { - using std::swap; - swap(a.ptr_, b.ptr_); -} - // Defines RE. // A simple C++ wrapper for . It uses the POSIX Extended @@ -2652,7 +2557,7 @@ inline void FlushInfoLog() { fflush(NULL); } // // GTEST_CHECK_ is an all-mode assert. It aborts the program if the condition // is not satisfied. -// Synopsis: +// Synopsys: // GTEST_CHECK_(boolean_condition); // or // GTEST_CHECK_(boolean_condition) << "Additional message"; @@ -2696,7 +2601,7 @@ const T& move(const T& t) { // 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 convertible to a target type. +// instead of an argument type convertable to a target type. // // The syntax for using ImplicitCast_ is the same as for static_cast: // @@ -2764,7 +2669,7 @@ Derived* CheckedDowncastToActualType(Base* base) { GTEST_CHECK_(typeid(*base) == typeid(Derived)); #endif -#if defined(GTEST_HAS_DOWNCAST_) && GTEST_HAS_DOWNCAST_ +#if GTEST_HAS_DOWNCAST_ return ::down_cast(base); #elif GTEST_HAS_RTTI return dynamic_cast(base); // NOLINT @@ -3063,7 +2968,7 @@ class GTEST_API_ Mutex { // by the linker. MutexType type_; long critical_section_init_phase_; // NOLINT - GTEST_CRITICAL_SECTION* critical_section_; + _RTL_CRITICAL_SECTION* critical_section_; GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex); }; @@ -3755,7 +3660,7 @@ inline int Close(int fd) { return close(fd); } inline const char* StrError(int errnum) { return strerror(errnum); } #endif inline const char* GetEnv(const char* name) { -#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT +#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE | GTEST_OS_WINDOWS_RT // We are on Windows CE, which has no environment variables. static_cast(name); // To prevent 'unused argument' warning. return NULL; @@ -3787,7 +3692,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 defined(_MSC_VER) && _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE +#if _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__) @@ -4552,7 +4457,7 @@ class GTEST_API_ FilePath { void Normalize(); - // Returns a pointer to the last occurrence of a valid path separator in + // Returns a pointer to the last occurence 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; @@ -7975,7 +7880,6 @@ GTEST_API_ std::string AppendUserMessage( // errors presumably detectable only at run time. Since // std::runtime_error inherits from std::exception, many testing // frameworks know how to extract and print the message inside it. - class GTEST_API_ GoogleTestFailureException : public ::std::runtime_error { public: explicit GoogleTestFailureException(const TestPartResult& failure); @@ -8006,7 +7910,7 @@ namespace edit_distance { // Returns the optimal edits to go from 'left' to 'right'. // All edits cost the same, with replace having lower priority than // add/remove. -// Simple implementation of the Wagner-Fischer algorithm. +// Simple implementation of the Wagner–Fischer algorithm. // See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm enum EditType { kMatch, kAdd, kRemove, kReplace }; GTEST_API_ std::vector CalculateOptimalEdits( @@ -9013,7 +8917,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 -// representation of expression as it was passed into the EXPECT_TRUE. +// represenation 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_ = \ @@ -10325,7 +10229,7 @@ class TypeWithoutFormatter { // 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 = static_cast(value); + const internal::BiggestInt kBigInt = value; *os << kBigInt; } }; @@ -11539,15 +11443,12 @@ typename ParamNameGenFunc::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 ParameterizedTestFactory : public internal::TestFactoryBase { +class ParameterizedTestFactory : public TestFactoryBase { public: typedef typename TestClass::ParamType ParamType; explicit ParameterizedTestFactory(ParamType parameter) : @@ -11562,8 +11463,6 @@ class ParameterizedTestFactory : public internal::TestFactoryBase { GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory); }; -} // namespace -namespace internal { // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // @@ -18245,9 +18144,9 @@ internal::CartesianProductHolder10 \ + ::testing::internal::ParamGenerator \ gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \ - static ::std::string gtest_##prefix##test_case_name##_EvalGenerateName_( \ + ::std::string gtest_##prefix##test_case_name##_EvalGenerateName_( \ const ::testing::TestParamInfo& info) { \ return ::testing::internal::GetParamNameGen \ (__VA_ARGS__)(info); \ @@ -18469,7 +18368,7 @@ class GTEST_API_ TestPartResultArray { }; // This interface knows how to report a test part result. -class GTEST_API_ TestPartResultReporterInterface { +class TestPartResultReporterInterface { public: virtual ~TestPartResultReporterInterface() {} @@ -18803,9 +18702,6 @@ GTEST_DECLARE_string_(color); // the tests to run. If the filter is not given all tests are executed. GTEST_DECLARE_string_(filter); -// 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); @@ -19990,7 +19886,7 @@ class GTEST_API_ UnitTest { internal::UnitTestImpl* impl() { return impl_; } const internal::UnitTestImpl* impl() const { return impl_; } - // These classes and functions are friends as they need to access private + // These classes and funcions are friends as they need to access private // members of UnitTest. friend class Test; friend class internal::AssertHelper; @@ -20394,8 +20290,8 @@ class GTEST_API_ AssertHelper { : type(t), file(srcfile), line(line_num), message(msg) { } TestPartResult::Type const type; - const char* const file; - int const line; + const char* const file; + int const line; std::string const message; private: @@ -20410,12 +20306,6 @@ class GTEST_API_ AssertHelper { } // namespace internal #if GTEST_HAS_PARAM_TEST - -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 @@ -20462,28 +20352,29 @@ class WithParamInterface { // like writing 'WithParamInterface::GetParam()' for a test that // uses a fixture whose parameter type is int. const ParamType& GetParam() const { - GTEST_CHECK_(GetParameterPtrRef_() != NULL) + GTEST_CHECK_(parameter_ != NULL) << "GetParam() can only be called inside a value-parameterized test " << "-- did you intend to write TEST_P instead of TEST_F?"; - return *GetParameterPtrRef_(); + return *parameter_; } 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) { - GetParameterPtrRef_() = parameter; + parameter_ = parameter; } - static const ParamType*& GetParameterPtrRef_() - { - return (const ParamType*&)internal::g_parameter_; - } + // Static value used for accessing parameter during a test lifetime. + static const ParamType* parameter_; // TestClass must be a subclass of WithParamInterface and Test. - template friend class /*internal::*/ParameterizedTestFactory; + template friend class internal::ParameterizedTestFactory; }; +template +const T* WithParamInterface::parameter_ = NULL; + // Most value-parameterized classes can ignore the existence of // WithParamInterface, and can just inherit from ::testing::TestWithParam. diff --git a/modules/ts/src/ts_gtest.cpp b/modules/ts/src/ts_gtest.cpp index f71efbb0eb..4f8c08aa3d 100644 --- a/modules/ts/src/ts_gtest.cpp +++ b/modules/ts/src/ts_gtest.cpp @@ -36,15 +36,7 @@ // This line ensures that gtest.h can be compiled on its own, even // when it's fused. -#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 +#include "gtest/gtest.h" // The following lines pull in the real gtest *.cc files. // Copyright 2005, Google Inc. @@ -506,7 +498,6 @@ 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"; @@ -586,7 +577,6 @@ 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); @@ -608,7 +598,6 @@ 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_; @@ -630,7 +619,6 @@ 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_; @@ -1359,7 +1347,6 @@ GTEST_API_ bool IsAsciiWhiteSpace(char ch); GTEST_API_ bool IsAsciiWordChar(char ch); GTEST_API_ bool IsValidEscape(char ch); GTEST_API_ bool AtomMatchesChar(bool escaped, char pattern, char ch); -GTEST_API_ std::string FormatRegexSyntaxError(const char* regex, int index); GTEST_API_ bool ValidateRegex(const char* regex); GTEST_API_ bool MatchRegexAtHead(const char* regex, const char* str); GTEST_API_ bool MatchRepetitionAndRegexAtHead( @@ -1693,12 +1680,6 @@ GTEST_DEFINE_string_( "exclude). A test is run if it matches one of the positive " "patterns and does not match any of the negative patterns."); -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."); @@ -2095,7 +2076,7 @@ extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId(); // This predicate-formatter checks that 'results' contains a test part // failure of the given type and that the failure message contains the // given substring. -static AssertionResult HasOneFailure(const char* /* results_expr */, +AssertionResult HasOneFailure(const char* /* results_expr */, const char* /* type_expr */, const char* /* substr_expr */, const TestPartResultArray& results, @@ -2638,7 +2619,7 @@ class Hunk { // Print a unified diff header for one hunk. // The format is // "@@ -, +, @@" - // where the left/right parts are omitted if unnecessary. + // where the left/right parts are ommitted if unnecessary. void PrintHeader(std::ostream* ss) const { *ss << "@@ "; if (removes_) { @@ -3605,7 +3586,7 @@ static std::string FormatWordList(const std::vector& words) { return word_list.GetString(); } -static bool ValidateTestPropertyName(const std::string& property_name, +bool ValidateTestPropertyName(const std::string& property_name, const std::vector& reserved_names) { if (std::find(reserved_names.begin(), reserved_names.end(), property_name) != reserved_names.end()) { @@ -3834,7 +3815,7 @@ static std::string PrintTestPartResultToString( GoogleTestFailureException::GoogleTestFailureException( const TestPartResult& failure) - : ::std::runtime_error(PrintTestPartResultToString(failure).c_str()) {} + : ::std::runtime_error(PrintTestPartResultToString(failure).c_str()) {} #endif // GTEST_HAS_EXCEPTIONS @@ -4368,7 +4349,7 @@ WORD GetColorAttribute(GTestColor color) { // Returns the ANSI color code for the given color. COLOR_DEFAULT is // an invalid input. -static const char* GetAnsiColorCode(GTestColor color) { +const char* GetAnsiColorCode(GTestColor color) { switch (color) { case COLOR_RED: return "1"; case COLOR_GREEN: return "2"; @@ -4420,7 +4401,7 @@ bool ShouldUseColor(bool stdout_is_tty) { // cannot simply emit special characters and have the terminal change colors. // This routine must actually emit the characters rather than return a string // that would be colored when printed, as can be done on Linux. -static void ColoredPrintf(GTestColor color, const char* fmt, ...) { +void ColoredPrintf(GTestColor color, const char* fmt, ...) { va_list args; va_start(args, fmt); @@ -4473,7 +4454,7 @@ static void ColoredPrintf(GTestColor color, const char* fmt, ...) { static const char kTypeParamLabel[] = "TypeParam"; static const char kValueParamLabel[] = "GetParam()"; -static void PrintFullTestCommentIfPresent(const TestInfo& test_info) { +void PrintFullTestCommentIfPresent(const TestInfo& test_info) { const char* const type_param = test_info.type_param(); const char* const value_param = test_info.value_param(); @@ -4534,14 +4515,6 @@ 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, @@ -4586,7 +4559,6 @@ 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); } @@ -4956,38 +4928,38 @@ std::string XmlUnitTestResultPrinter::EscapeXml( for (size_t i = 0; i < str.size(); ++i) { const char ch = str[i]; switch (ch) { - case '<': - m << "<"; - break; - case '>': - m << ">"; - break; - case '&': - m << "&"; - break; - case '\'': - if (is_attribute) - m << "'"; - else - m << '\''; - break; - case '"': - if (is_attribute) - m << """; - else - m << '"'; - break; - default: + case '<': + m << "<"; + break; + case '>': + m << ">"; + break; + case '&': + m << "&"; + break; + case '\'': + if (is_attribute) + m << "'"; + else + m << '\''; + break; + case '"': + if (is_attribute) + m << """; + else + m << '"'; + break; + default: if (IsValidXmlCharacter(ch)) { if (is_attribute && IsNormalizableWhitespace(ch)) m << "&#x" << String::FormatByte(static_cast(ch)) << ";"; - else + else m << ch; - } - break; - } + } + break; } + } return m.GetString(); } @@ -5445,7 +5417,7 @@ void TestEventListeners::SuppressEventForwarding() { // We don't protect this under mutex_ as a user is not supposed to // call this before main() starts, from which point on the return // value will never change. -UnitTest * UnitTest::GetInstance() { +UnitTest* UnitTest::GetInstance() { // When compiled with MSVC 7.1 in optimized mode, destroying the // UnitTest object upon exiting the program messes up the exit code, // causing successful tests to appear failed. We have to use a @@ -5457,13 +5429,13 @@ UnitTest * UnitTest::GetInstance() { // default implementation. Use this implementation to keep good OO // design with private destructor. -#if (defined(_MSC_VER) && _MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__) +#if (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__) static UnitTest* const instance = new UnitTest; return instance; #else static UnitTest instance; return &instance; -#endif // (defined(_MSC_VER) && _MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__) +#endif // (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__) } // Gets the number of successful test cases. @@ -6291,15 +6263,9 @@ 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) && - internal::UnitTestOptions::MatchesFilter(value_param, - GTEST_FLAG(param_filter).c_str()); - + test_name); test_info->matches_filter_ = matches_filter; const bool is_runnable = @@ -6364,7 +6330,7 @@ void UnitTestImpl::ListTestsMatchingFilter() { // We print the type parameter on a single line to make // the output easy to parse by a program. PrintOnOneLine(test_case->type_param(), kMaxParamLength); - } + } printf("\n"); } printf(" %s", test_info->name()); @@ -6494,7 +6460,7 @@ bool SkipPrefix(const char* prefix, const char** pstr) { // part can be omitted. // // Returns the value of the flag, or NULL if the parsing failed. -static const char* ParseFlagValue(const char* str, +const char* ParseFlagValue(const char* str, const char* flag, bool def_optional) { // str and flag must not be NULL. @@ -6532,7 +6498,7 @@ static const char* ParseFlagValue(const char* str, // // On success, stores the value of the flag in *value, and returns // true. On failure, returns false without changing *value. -static bool ParseBoolFlag(const char* str, const char* flag, bool* value) { +bool ParseBoolFlag(const char* str, const char* flag, bool* value) { // Gets the value of the flag as a string. const char* const value_str = ParseFlagValue(str, flag, true); @@ -6566,7 +6532,7 @@ bool ParseInt32Flag(const char* str, const char* flag, Int32* value) { // // On success, stores the value of the flag in *value, and returns // true. On failure, returns false without changing *value. -static bool ParseStringFlag(const char* str, const char* flag, std::string* value) { +bool ParseStringFlag(const char* str, const char* flag, std::string* value) { // Gets the value of the flag as a string. const char* const value_str = ParseFlagValue(str, flag, false); @@ -6651,12 +6617,6 @@ 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" @@ -6708,7 +6668,7 @@ static const char kColorEncodedHelpMessage[] = "(not one in your own code or tests), please report it to\n" "@G<" GTEST_DEV_EMAIL_ ">@D.\n"; -static bool ParseGoogleTestFlag(const char* const arg) { +bool ParseGoogleTestFlag(const char* const arg) { return ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag, >EST_FLAG(also_run_disabled_tests)) || ParseBoolFlag(arg, kBreakOnFailureFlag, @@ -6721,7 +6681,6 @@ 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)) || @@ -6739,7 +6698,7 @@ static bool ParseGoogleTestFlag(const char* const arg) { } #if GTEST_USE_OWN_FLAGFILE_FLAG_ -static void LoadFlagsFromFile(const std::string& path) { +void LoadFlagsFromFile(const std::string& path) { FILE* flagfile = posix::FOpen(path.c_str(), "r"); if (!flagfile) { fprintf(stderr, @@ -7130,7 +7089,7 @@ enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW }; // message is propagated back to the parent process. Otherwise, the // message is simply printed to stderr. In either case, the program // then exits with status 1. -static void DeathTestAbort(const std::string& message) { +void DeathTestAbort(const std::string& message) { // On a POSIX system, this function may be called from a threadsafe-style // death test child process, which operates on a very small stack. Use // the heap for any additional non-minuscule memory requirements. @@ -7872,15 +7831,14 @@ void StackLowerThanAddress(const void* ptr, bool* result) { *result = (&dummy < ptr); } -#if GTEST_HAS_CLONE +// Make sure AddressSanitizer does not tamper with the stack here. GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ -static bool StackGrowsDown() { +bool StackGrowsDown() { int dummy; bool result; StackLowerThanAddress(&dummy, &result); return result; } -#endif // Spawns a child process with the same executable as the current process in // a thread-safe manner and instructs it to run the death test. The @@ -8066,6 +8024,7 @@ bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex, } # if GTEST_OS_WINDOWS + if (GTEST_FLAG(death_test_style) == "threadsafe" || GTEST_FLAG(death_test_style) == "fast") { *test = new WindowsDeathTest(statement, regex, file, line); @@ -8174,6 +8133,7 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() { int write_fd = -1; # if GTEST_OS_WINDOWS + unsigned int parent_process_id = 0; size_t write_handle_as_size_t = 0; size_t event_handle_as_size_t = 0; @@ -8278,7 +8238,6 @@ 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 @@ -8292,7 +8251,6 @@ const char kCurrentDirectoryString[] = ".\\"; # endif // GTEST_OS_WINDOWS_MOBILE #else const char kPathSeparator = '/'; -//const char kPathSeparatorString[] = "/"; const char kCurrentDirectoryString[] = "./"; #endif // GTEST_OS_WINDOWS @@ -8340,7 +8298,7 @@ FilePath FilePath::RemoveExtension(const char* extension) const { return *this; } -// Returns a pointer to the last occurrence of a valid path separator in +// Returns a pointer to the last occurence 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* FilePath::FindLastPathSeparator() const { @@ -9606,7 +9564,7 @@ static CapturedStream* g_captured_stderr = NULL; static CapturedStream* g_captured_stdout = NULL; // Starts capturing an output stream (stdout/stderr). -static void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) { +void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) { if (*stream != NULL) { GTEST_LOG_(FATAL) << "Only one " << stream_name << " capturer can exist at a time."; @@ -9615,7 +9573,7 @@ static void CaptureStream(int fd, const char* stream_name, CapturedStream** stre } // Stops capturing the output stream and returns the captured string. -static std::string GetCapturedStream(CapturedStream** captured_stream) { +std::string GetCapturedStream(CapturedStream** captured_stream) { const std::string content = (*captured_stream)->GetCapturedString(); delete *captured_stream; @@ -9971,7 +9929,7 @@ namespace internal { // Depending on the value of a char (or wchar_t), we print it in one // of three formats: // - as is if it's a printable ASCII (e.g. 'a', '2', ' '), -// - as a hexadecimal escape sequence (e.g. '\x7F'), or +// - as a hexidecimal escape sequence (e.g. '\x7F'), or // - as a special escape sequence (e.g. '\r', '\n'). enum CharFormat { kAsIs, @@ -10075,7 +10033,7 @@ void PrintCharAndCodeTo(Char c, ostream* os) { return; *os << " (" << static_cast(c); - // For more convenience, we print c's code again in hexadecimal, + // For more convenience, we print c's code again in hexidecimal, // unless c was already printed in the form '\x##' or the code is in // [1, 9]. if (format == kHexEscape || (1 <= c && c <= 9)) { @@ -10441,7 +10399,5 @@ const char* TypedTestCasePState::VerifyRegisteredTestNames( #endif // GTEST_HAS_TYPED_TEST_P -void* g_parameter_ = NULL; - } // namespace internal } // namespace testing