Skip to content

Add 71 comprehensive tests to increase code coverage#18

Merged
rkillick merged 1 commit intorkillick:mainfrom
Delta17920:main
Mar 26, 2026
Merged

Add 71 comprehensive tests to increase code coverage#18
rkillick merged 1 commit intorkillick:mainfrom
Delta17920:main

Conversation

@Delta17920
Copy link
Copy Markdown
Contributor

Summary

This PR introduces a new test suite (test_new_coverage.R) containing 71 comprehensive tests targeting the changepoint regression functions. It significantly increases the package's code coverage, specifically aiming at the previously untested non-exported functions and edge cases in model selection.

Code Coverage Impact

Overall package coverage increased from 0.97% to 59.25%.

  • R/CptReg.R: 0.00% ➔ 94.35%
  • R/envcpt.R: 0.00% ➔ 80.45%
  • src/C_cptreg.c: 1.77% ➔ 83.63%

Tests Added (71 Total)

1. cpt.reg (Input Validation & Functionality):

  • Exhaustive input validation (data types, arrays, invalid penalties, methods, distributions, tol, minseglen bounds).
  • Edge cases for minseglen warnings and errors.
  • S4 class output verification (cpt.reg), plus tests for class=FALSE and param.estimates=FALSE.
  • Accuracy checks for PELT and AMOC algorithms on AR(1) and AR(2) simulated data.
  • Penalty edge cases (AIC, BIC, shape parameters for RSS and fixed variance).
  • Support verification for 3D array inputs and trend data.

2. check_data & ChangepointRegression (Internal Routing):

  • Matrix dimension validation and regressor vs. observation counts.
  • Warning triggers for missing or duplicate intercepts.
  • Method dispatching verification (AMOC vs. PELT) and cpts.only sorting logic.

3. envcpt (Model Subsets):

  • Verification of model selection indexing (models = "meanar1cpt", models = c(5, 6)).
  • minseglen propagation to internal calls.
  • Detection accuracy within the subset models.

4. Penalty Weights & C-Level Dispatch (AICweights, BIC, CptReg_*):

  • Structure, length, and summation bounds (weights sum to 1, all non-negative).
  • Invalid object and matrix dimension error handling.
  • Direct validation of CptReg_AMOC_Normal and CptReg_PELT_Normal.

GSoC 2026 Contributor Test Submission
Contributor: Pratik (@Delta17920)

@rkillick rkillick merged commit c3c61fb into rkillick:main Mar 26, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants