Add unit tests for traincascade library#22
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces a doctest-based unit test suite for the traincascade library, wires it into CI across Ubuntu / macOS / Windows, and registers the test target with the top-level CTest runner.
Motivation
The traincascade library previously had a doctest harness scaffolded (main.cpp) but no actual test cases. This MR fills that gap with a comprehensive unit test suite focused on the library's pure / configuration surface, and ensures the tests run automatically on every push.
Changes
New test files
icvCmpIntegers,cvAlign,CV_DTREE_CAT_DIR,LessThanIdx,LessThanPtr,cvPreprocessIndexArray,BlockedRange/parallel_for/parallel_reduce,CvDTreeNode::get_num_valid/set_num_validCvDTreeParams,CvBoostParams,CvCascadeBoostParams,CvCascadeParams(default + parameterized ctors,scanAttr)CvFeatureParams::create,CvFeatureEvaluator::create,CvHaarFeatureParams/CvLBPFeatureParams/CvHOGFeatureParams, evaluatorinit/generateFeatures/setImageCvCascadeImageReader::createfailure pathsAll tests follow the Arrange–Act–Assert pattern with explicit comments and cover both the happy path and edge cases (out-of-range indices, duplicates, multi-dimensional inputs, unsupported types, empty ranges, null vs. allocated
num_valid, too-small HOG window, unknown attribute names, missing files, …).Build system
test_traincascadetarget.-Wold-style-cast,-Wsign-conversion,-Wconversionfrom the test target only — these are triggered by inline definitions in the library's public headers (haarfeatures.h, lbpfeatures.h, HOGfeatures.h, traincascade_features.h) which the library itself does not enable.include(CTest)+enable_testing()at the project root soctestdiscovers the test from the top-level build directory.CI
Added a
Teststep after the build step in:Each runs
ctest --output-on-failure -C $BUILD_TYPEfrom the top-level build directory.Test results
CTest from the top-level build directory:
Coverage
Measured with clang
-fprofile-instr-generate -fcoverage-mapping:o_cvdtree*,o_cvboost*,o_cvcascadeboost*,o_cvstatmodel.cppThe suite achieves near-complete coverage of the public configuration surface (params + factories). The uncovered code is the heavyweight ML training internals reachable only through
CvCascadeClassifier::train, which would require integration-style fixtures (real.vec+ bg.txt) or further refactoring to be unit-testable.Verification
-Werrorflags.ctestdiscovers and runs the suite from the top-level build dir.Out of scope / follow-ups
CvCascadeClassifier::trainusing the existing samples in res.read/writeviacv::FileStorage) for*Paramstypes.setImage/operator()numerical tests on synthetic images for each feature evaluator.