mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
ts: refactor OpenCV tests
- removed tr1 usage (dropped in C++17) - moved includes of vector/map/iostream/limits into ts.hpp - require opencv_test + anonymous namespace (added compile check) - fixed norm() usage (must be from cvtest::norm for checks) and other conflict functions - added missing license headers
This commit is contained in:
@@ -21,13 +21,21 @@
|
||||
|
||||
#include "cvconfig.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <cstdio>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <numeric>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
#ifdef WINRT
|
||||
#pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
|
||||
@@ -72,11 +80,35 @@ namespace cvtest
|
||||
{
|
||||
|
||||
using std::vector;
|
||||
using std::map;
|
||||
using std::string;
|
||||
using namespace cv;
|
||||
using std::stringstream;
|
||||
using std::cout;
|
||||
using std::cerr;
|
||||
using std::endl;
|
||||
using std::min;
|
||||
using std::max;
|
||||
using std::numeric_limits;
|
||||
using std::pair;
|
||||
using std::make_pair;
|
||||
using testing::TestWithParam;
|
||||
using testing::Values;
|
||||
using testing::Combine;
|
||||
|
||||
using cv::Mat;
|
||||
using cv::Mat_;
|
||||
using cv::UMat;
|
||||
using cv::InputArray;
|
||||
using cv::OutputArray;
|
||||
using cv::noArray;
|
||||
|
||||
using cv::Range;
|
||||
using cv::Point;
|
||||
using cv::Rect;
|
||||
using cv::Size;
|
||||
using cv::Scalar;
|
||||
using cv::RNG;
|
||||
|
||||
// Tuple stuff from Google Tests
|
||||
using testing::get;
|
||||
using testing::make_tuple;
|
||||
@@ -669,6 +701,7 @@ int main(int argc, char **argv) \
|
||||
|
||||
namespace cvtest {
|
||||
using perf::MatDepth;
|
||||
using perf::MatType;
|
||||
}
|
||||
|
||||
#ifdef WINRT
|
||||
@@ -770,4 +803,31 @@ public:
|
||||
#endif // __FSTREAM_EMULATED__
|
||||
#endif // WINRT
|
||||
|
||||
|
||||
namespace opencv_test {
|
||||
using namespace cvtest;
|
||||
using namespace cv;
|
||||
|
||||
#ifdef CV_CXX11
|
||||
#define CVTEST_GUARD_SYMBOL(name) \
|
||||
class required_namespace_specificatin_here_for_symbol_ ## name {}; \
|
||||
using name = required_namespace_specificatin_here_for_symbol_ ## name;
|
||||
#else
|
||||
#define CVTEST_GUARD_SYMBOL(name) /* nothing */
|
||||
#endif
|
||||
|
||||
CVTEST_GUARD_SYMBOL(norm)
|
||||
CVTEST_GUARD_SYMBOL(add)
|
||||
CVTEST_GUARD_SYMBOL(multiply)
|
||||
CVTEST_GUARD_SYMBOL(divide)
|
||||
CVTEST_GUARD_SYMBOL(transpose)
|
||||
CVTEST_GUARD_SYMBOL(copyMakeBorder)
|
||||
CVTEST_GUARD_SYMBOL(filter2D)
|
||||
CVTEST_GUARD_SYMBOL(compare)
|
||||
CVTEST_GUARD_SYMBOL(minMaxIdx)
|
||||
CVTEST_GUARD_SYMBOL(threshold)
|
||||
|
||||
extern bool required_opencv_test_namespace; // compilation check for non-refactored tests
|
||||
}
|
||||
|
||||
#endif // OPENCV_TS_HPP
|
||||
|
||||
@@ -364,4 +364,9 @@ CV_ENUM(BorderType, BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT, BORDER_WR
|
||||
|
||||
} } // namespace cvtest::ocl
|
||||
|
||||
namespace opencv_test {
|
||||
namespace ocl {
|
||||
using namespace cvtest::ocl;
|
||||
}} // namespace
|
||||
|
||||
#endif // OPENCV_TS_OCL_TEST_HPP
|
||||
|
||||
@@ -14,7 +14,15 @@ extern bool skipUnstableTests;
|
||||
extern int testThreads;
|
||||
}
|
||||
|
||||
// check for required "opencv_test" namespace
|
||||
#if !defined(CV_TEST_SKIP_NAMESPACE_CHECK) && defined(__OPENCV_BUILD)
|
||||
#define CV__TEST_NAMESPACE_CHECK required_opencv_test_namespace = true;
|
||||
#else
|
||||
#define CV__TEST_NAMESPACE_CHECK // nothing
|
||||
#endif
|
||||
|
||||
#define CV__TEST_INIT \
|
||||
CV__TEST_NAMESPACE_CHECK \
|
||||
cv::ipp::setIppStatus(0); \
|
||||
cv::theRNG().state = cvtest::param_seed; \
|
||||
cv::setNumThreads(cvtest::testThreads);
|
||||
|
||||
@@ -18240,9 +18240,9 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
|
||||
// alphanumeric characters or underscore.
|
||||
|
||||
# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, ...) \
|
||||
::testing::internal::ParamGenerator<test_case_name::ParamType> \
|
||||
static ::testing::internal::ParamGenerator<test_case_name::ParamType> \
|
||||
gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \
|
||||
::std::string gtest_##prefix##test_case_name##_EvalGenerateName_( \
|
||||
static ::std::string gtest_##prefix##test_case_name##_EvalGenerateName_( \
|
||||
const ::testing::TestParamInfo<test_case_name::ParamType>& info) { \
|
||||
return ::testing::internal::GetParamNameGen<test_case_name::ParamType> \
|
||||
(__VA_ARGS__)(info); \
|
||||
|
||||
@@ -526,6 +526,7 @@ void PrintTo(const Size& sz, ::std::ostream* os);
|
||||
|
||||
#define CV__PERF_TEST_BODY_IMPL(name) \
|
||||
{ \
|
||||
CV__TEST_NAMESPACE_CHECK \
|
||||
CV__TRACE_APP_FUNCTION_NAME("PERF_TEST: " name); \
|
||||
RunPerfTestBody(); \
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user