From 37d695a62ea84a0a3dc483c45e610202c26bf582 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Wed, 6 Feb 2013 15:07:31 +0400 Subject: [PATCH] Use gtest assertions in cascade test This simplifies test debugging a lot --- modules/objdetect/test/test_cascadeandhog.cpp | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/modules/objdetect/test/test_cascadeandhog.cpp b/modules/objdetect/test/test_cascadeandhog.cpp index 596e646517..41ecb3fdeb 100644 --- a/modules/objdetect/test/test_cascadeandhog.cpp +++ b/modules/objdetect/test/test_cascadeandhog.cpp @@ -363,22 +363,20 @@ int CV_DetectorTest::validate( int detectorIdx, vector >& objects ) } noPair += (int)count_if( map.begin(), map.end(), isZero ); totalNoPair += noPair; - if( noPair > cvRound(valRects.size()*eps.noPair)+1 ) + + EXPECT_LE(noPair, cvRound(valRects.size()*eps.noPair)+1) + << "detector " << detectorNames[detectorIdx] << " has overrated count of rectangles without pair on " + << imageFilenames[imageIdx] << " image"; + + if (::testing::Test::HasFailure()) break; } - if( imageIdx < (int)imageFilenames.size() ) - { - char msg[500]; - sprintf( msg, "detector %s has overrated count of rectangles without pair on %s-image\n", - detectorNames[detectorIdx].c_str(), imageFilenames[imageIdx].c_str() ); - ts->printf( cvtest::TS::LOG, msg ); - return cvtest::TS::FAIL_BAD_ACCURACY; - } - if ( totalNoPair > cvRound(totalValRectCount*eps./*total*/noPair)+1 ) - { - ts->printf( cvtest::TS::LOG, "overrated count of rectangles without pair on all images set" ); + + EXPECT_LE(totalNoPair, cvRound(totalValRectCount*eps./*total*/noPair)+1) + << "detector " << detectorNames[detectorIdx] << " has overrated count of rectangles without pair on all images set"; + + if (::testing::Test::HasFailure()) return cvtest::TS::FAIL_BAD_ACCURACY; - } return cvtest::TS::OK; }