Fixed verbosity of badarg tests

This commit is contained in:
Andrey Kamaev 2012-04-19 15:45:40 +00:00
parent dbccc9b129
commit 3a4c14e549
2 changed files with 16 additions and 10 deletions

View File

@ -1990,7 +1990,8 @@ bool cv::findCirclesGrid( InputArray _image, Size patternSize,
bool isFound = false; bool isFound = false;
#define BE_QUIET 1 #define BE_QUIET 1
#if BE_QUIET #if BE_QUIET
redirectError(quiet_error); void* oldCbkData;
ErrorCallback oldCbk = redirectError(quiet_error, 0, &oldCbkData);
#endif #endif
try try
{ {
@ -2001,7 +2002,7 @@ bool cv::findCirclesGrid( InputArray _image, Size patternSize,
} }
#if BE_QUIET #if BE_QUIET
redirectError(0); redirectError(oldCbk, oldCbkData);
#endif #endif
if (isFound) if (isFound)
{ {

View File

@ -319,6 +319,8 @@ BadArgTest::BadArgTest()
progress = -1; progress = -1;
test_case_idx = -1; test_case_idx = -1;
freq = cv::getTickFrequency(); freq = cv::getTickFrequency();
// oldErrorCbk = 0;
// oldErrorCbkData = 0;
} }
BadArgTest::~BadArgTest(void) BadArgTest::~BadArgTest(void)
@ -378,7 +380,6 @@ int BadArgTest::run_test_case( int expected_code, const string& _descr )
return errcount; return errcount;
} }
/*****************************************************************************************\ /*****************************************************************************************\
* Base Class for Test System * * Base Class for Test System *
\*****************************************************************************************/ \*****************************************************************************************/
@ -438,6 +439,12 @@ string TS::str_from_code( int code )
return "Generic/Unknown"; return "Generic/Unknown";
} }
static int tsErrorCallback( int status, const char* func_name, const char* err_msg, const char* file_name, int line, TS* ts )
{
ts->printf(TS::LOG, "OpenCV Error: %s (%s) in %s, file %s, line %d\n", cvErrorStr(status), err_msg, func_name[0] != 0 ? func_name : "unknown function", file_name, line);
return 0;
}
/************************************** Running tests **********************************/ /************************************** Running tests **********************************/
void TS::init( const string& modulename ) void TS::init( const string& modulename )
@ -453,10 +460,10 @@ void TS::init( const string& modulename )
data_path = string(buf); data_path = string(buf);
} }
cv::redirectError((cv::ErrorCallback)tsErrorCallback, this);
if( ::testing::GTEST_FLAG(catch_exceptions) ) if( ::testing::GTEST_FLAG(catch_exceptions) )
{ {
cvSetErrMode( CV_ErrModeParent );
cvRedirectError( cvStdErrReport );
#if defined WIN32 || defined _WIN32 #if defined WIN32 || defined _WIN32
#ifdef _MSC_VER #ifdef _MSC_VER
_set_se_translator( SEHTranslator ); _set_se_translator( SEHTranslator );
@ -468,8 +475,6 @@ void TS::init( const string& modulename )
} }
else else
{ {
cvSetErrMode( CV_ErrModeLeaf );
cvRedirectError( cvGuiBoxReport );
#if defined WIN32 || defined _WIN32 #if defined WIN32 || defined _WIN32
#ifdef _MSC_VER #ifdef _MSC_VER
_set_se_translator( 0 ); _set_se_translator( 0 );