Add unit tests for StandardRetrospectiveCorrection#32
Open
ps2 wants to merge 1 commit into
Open
Conversation
StandardRetrospectiveCorrection (the P-only retrospective correction controller) had no dedicated unit tests — its behavior was only covered transitively via the higher-level LoopAlgorithm tests. Adds 9 tests covering: - Recency gating: stale / nil / empty discrepancy lists clear the correction and return empty. - Total correction effect equals the latest (most-recent) discrepancy magnitude (Standard is P-only on .last). - Positive / negative discrepancies project glucose forward in the expected direction, with the last sample ≈ starting + discrepancy. - The first effect sample equals the starting glucose value at the starting date (correction hasn't yet had time to apply). - Only the latest discrepancy contributes — older entries are ignored (the key behavioral difference vs IntegralRC, which integrates them). - Short discrepancies are clamped to retrospectiveCorrectionGroupingInterval to prevent over-amplified velocity from very short windows. These tests will serve as a backstop while the active-insulin / EGP decomposition work modifies the glucose-effect computation upstream of the RC discrepancy calculation.
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
StandardRetrospectiveCorrection(the P-only retrospective correction controller) had no dedicated unit tests — its behavior was only covered transitively via the higher-levelLoopAlgorithmtests. Adds 9 focused tests inStandardRetrospectiveCorrectionTests.swift.Tests
.lastfrom the discrepancy list. Verified that older entries are ignored even when they would change the answer.retrospectiveCorrectionGroupingIntervaluse the grouping interval as the velocity-denominator (preventing over-amplified projections from very short windows).Test plan
xcrun swift test --filter StandardRetrospectiveCorrectionTests)Note
This intentionally does NOT add tests to
IntegralRetrospectiveCorrection's existing test file — IRC's test surface is being shaped separately.