提交 2df096c1 编写于 作者: A Andrey Morozov

converted drawing tests to the format of google test system

上级 c8f0147a
...@@ -40,17 +40,16 @@ ...@@ -40,17 +40,16 @@
//M*/ //M*/
#include "test_precomp.hpp" #include "test_precomp.hpp"
#include "opencv2/highgui/highgui.hpp"
#if 0
using namespace cv; using namespace cv;
//#define DRAW_TEST_IMAGE //#define DRAW_TEST_IMAGE
class CV_DrawingTest : public CvTest class CV_DrawingTest : public cvtest::BaseTest
{ {
public: public:
CV_DrawingTest( const char* testName ) : CvTest( testName, "drawing funcs" ) {} CV_DrawingTest( const char* testName ){}
protected: protected:
void run( int ); void run( int );
virtual void draw( Mat& img ) = 0; virtual void draw( Mat& img ) = 0;
...@@ -59,7 +58,6 @@ protected: ...@@ -59,7 +58,6 @@ protected:
void CV_DrawingTest::run( int ) void CV_DrawingTest::run( int )
{ {
int code = CvTS::OK;
Mat testImg, valImg; Mat testImg, valImg;
const string name = "drawing/image.jpg"; const string name = "drawing/image.jpg";
string path = ts->get_data_path(), filename; string path = ts->get_data_path(), filename;
...@@ -73,8 +71,8 @@ void CV_DrawingTest::run( int ) ...@@ -73,8 +71,8 @@ void CV_DrawingTest::run( int )
valImg = imread( filename ); valImg = imread( filename );
if( valImg.empty() ) if( valImg.empty() )
{ {
ts->printf( CvTS::LOG, "test image can not be read"); ts->printf( ts->LOG, "test image can not be read");
code = CvTS::FAIL_INVALID_TEST_DATA; ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
} }
else else
{ {
...@@ -82,22 +80,22 @@ void CV_DrawingTest::run( int ) ...@@ -82,22 +80,22 @@ void CV_DrawingTest::run( int )
float Eps = 0.9f; float Eps = 0.9f;
if( err > Eps) if( err > Eps)
{ {
ts->printf( CvTS::LOG, "CV_RELATIVE_L1 between testImg and valImg is equal %f (larger than %f)\n", err, Eps ); ts->printf( ts->LOG, "CV_RELATIVE_L1 between testImg and valImg is equal %f (larger than %f)\n", err, Eps );
code = CvTS::FAIL_BAD_ACCURACY; ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
} }
else else
{ {
code = checkLineIterator( testImg ); ts->set_failed_test_info(checkLineIterator( testImg ));
} }
} }
#endif #endif
ts->set_failed_test_info( code ); ts->set_failed_test_info(cvtest::TS::OK);
} }
class CV_DrawingTest_CPP : public CV_DrawingTest class CV_DrawingTest_CPP : public cvtest::BaseTest
{ {
public: public:
CV_DrawingTest_CPP() : CV_DrawingTest( "drawing_cpp" ) {} CV_DrawingTest_CPP() {}
protected: protected:
virtual void draw( Mat& img ); virtual void draw( Mat& img );
virtual int checkLineIterator( Mat& img); virtual int checkLineIterator( Mat& img);
...@@ -235,17 +233,18 @@ int CV_DrawingTest_CPP::checkLineIterator( Mat& img ) ...@@ -235,17 +233,18 @@ int CV_DrawingTest_CPP::checkLineIterator( Mat& img )
float err = (float)norm( v ); float err = (float)norm( v );
if( err != 0 ) if( err != 0 )
{ {
ts->printf( CvTS::LOG, "LineIterator works incorrect" ); ts->printf( ts->LOG, "LineIterator works incorrect" );
return CvTS::FAIL_INVALID_OUTPUT; ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
} }
} }
return CvTS::OK; ts->set_failed_test_info(cvtest::TS::OK);
return 0;
} }
class CV_DrawingTest_C : public CV_DrawingTest class CV_DrawingTest_C : public cvtest::BaseTest
{ {
public: public:
CV_DrawingTest_C() : CV_DrawingTest( "drawing_c" ) {} CV_DrawingTest_C() {}
protected: protected:
virtual void draw( Mat& img ); virtual void draw( Mat& img );
virtual int checkLineIterator( Mat& img); virtual int checkLineIterator( Mat& img);
...@@ -400,15 +399,15 @@ int CV_DrawingTest_C::checkLineIterator( Mat& _img ) ...@@ -400,15 +399,15 @@ int CV_DrawingTest_C::checkLineIterator( Mat& _img )
float err = (float)norm( v ); float err = (float)norm( v );
if( err != 0 ) if( err != 0 )
{ {
ts->printf( CvTS::LOG, "CvLineIterator works incorrect" ); ts->printf( ts->LOG, "CvLineIterator works incorrect" );
return CvTS::FAIL_INVALID_OUTPUT; ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
} }
CV_NEXT_LINE_POINT(it); CV_NEXT_LINE_POINT(it);
} }
return CvTS::OK; ts->set_failed_test_info(cvtest::TS::OK);
return 0;
} }
CV_DrawingTest_CPP drawing_test_cpp; TEST(Highgui_Drawing_CPP, regression) { CV_DrawingTest_CPP test; test.safe_run(); }
CV_DrawingTest_C drawing_test_c; TEST(Highgui_Drawing_C, regression) { CV_DrawingTest_C test; test.safe_run(); }
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册