diff --git a/modules/dnn/test/test_precomp.hpp b/modules/dnn/test/test_precomp.hpp index 062308bf67..70b7b3d25e 100644 --- a/modules/dnn/test/test_precomp.hpp +++ b/modules/dnn/test/test_precomp.hpp @@ -49,7 +49,7 @@ #include "opencv2/dnn.hpp" #include "test_common.hpp" -namespace opencv_test { +namespace opencv_test { namespace { using namespace cv::dnn; CV_ENUM(DNNBackend, DNN_BACKEND_DEFAULT, DNN_BACKEND_HALIDE, DNN_BACKEND_INFERENCE_ENGINE) @@ -69,6 +69,6 @@ static testing::internal::ParamGenerator availableDnnTargets() return testing::ValuesIn(targets); } -} +}} #endif diff --git a/modules/ts/include/opencv2/ts/ts_gtest.h b/modules/ts/include/opencv2/ts/ts_gtest.h index 7c1854e9a5..2b1299c3bf 100644 --- a/modules/ts/include/opencv2/ts/ts_gtest.h +++ b/modules/ts/include/opencv2/ts/ts_gtest.h @@ -11539,12 +11539,15 @@ 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 TestFactoryBase { +class ParameterizedTestFactory : public internal::TestFactoryBase { public: typedef typename TestClass::ParamType ParamType; explicit ParameterizedTestFactory(ParamType parameter) : @@ -11559,6 +11562,8 @@ class ParameterizedTestFactory : public TestFactoryBase { GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory); }; +} // namespace +namespace internal { // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // @@ -20405,6 +20410,12 @@ 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 @@ -20451,29 +20462,28 @@ class WithParamInterface { // like writing 'WithParamInterface::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 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 ff9dd4a1bf..f71efbb0eb 100644 --- a/modules/ts/src/ts_gtest.cpp +++ b/modules/ts/src/ts_gtest.cpp @@ -10441,5 +10441,7 @@ const char* TypedTestCasePState::VerifyRegisteredTestNames( #endif // GTEST_HAS_TYPED_TEST_P +void* g_parameter_ = NULL; + } // namespace internal } // namespace testing