Skip to content

Test that chunking the input does not change the output - #164

Merged
lalinsky merged 2 commits into
masterfrom
test-unaligned-consume
Jul 28, 2026
Merged

lalinsky merged 2 commits into
masterfrom
test-unaligned-consume

Conversation

@acoustid-bot

Copy link
Copy Markdown
Contributor

Consume() now accepts a partial frame at the end of a call and carries it over to the next one (fb9460b). Nothing checked that the result is actually the same however the caller splits its input, and before that change Consume() asserted length % m_num_channels == 0, so this call pattern had no coverage at all.

Feeds the same stereo file in sizes that are deliberately not multiples of the channel count — 1, 2, 3, 5, 7, 17, 511, 997, 4096 — so every call but the last leaves a partial frame behind, and compares each result against a single Consume() of the whole buffer.

The test stores no expected output. It compares against whatever the single-call path produces, so it keeps working if the resampler, the target sample rate or the test audio ever change, and there is nothing to regenerate. It reuses LoadAudioFile, AudioBuffer and AudioProcessor as the surrounding tests do, and adds no fixtures or data files. SCOPED_TRACE names the chunk size on failure so the loop needs no per-case assertions.

Checked in both directions: it passes on master (~170 ms), and against the audio_processor.cpp from before fb9460b it trips that commit's length % m_num_channels == 0 assertion — so it exercises the behaviour rather than passing vacuously.

Mono is not covered because with one channel there is never a partial frame, so the loop would only be re-testing the aligned path.

Consume() now accepts a partial frame at the end of a call and carries it over
to the next one, but nothing checked that the result is the same however the
caller splits its input.

Feed the same stereo file in sizes that are not multiples of the channel count
and compare each result against a single Consume() of the whole buffer. Nothing
is stored as expected output, so the test keeps working if the resampler or the
test audio changes.
@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 09d02df8-36bd-419e-8993-486fa1925086

📥 Commits

Reviewing files that changed from the base of the PR and between 6967df8 and c3ecc5f.

📒 Files selected for processing (1)
  • tests/test_audio_processor.cpp

Walkthrough

Changes

AudioProcessor validation

Layer / File(s) Summary
Chunked consumption equivalence
tests/test_audio_processor.cpp
Adds a test comparing chunked Consume() calls with a single full-input call, including flush results, buffer sizes, and per-sample values. Includes <string> for chunk-size trace labels.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the new regression test verifying chunked input produces the same output as single-call consumption.
Description check ✅ Passed The description is directly about the added stereo chunking regression test and matches the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test-unaligned-consume

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/test_audio_processor.cpp`:
- Around line 125-128: Correct the comment above chunk_sizes to accurately
describe the test inputs: do not claim every call leaves a partial frame, and
acknowledge that 2 and 4096 are aligned with the stereo channel count, or remove
those aligned sizes if the test requires only non-multiples.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 044a46b6-1c37-4fe7-8a86-40be75181ec8

📥 Commits

Reviewing files that changed from the base of the PR and between 056bd71 and 6967df8.

📒 Files selected for processing (1)
  • tests/test_audio_processor.cpp

Comment thread tests/test_audio_processor.cpp Outdated
@acoustid-bot

Copy link
Copy Markdown
Contributor Author

Both points are correct, fixed in c3ecc5f.

2 and 4096 are indeed multiples of the channel count, and the second half of the sentence was wrong even for the odd sizes — with chunk_size = 3 and two channels the leftover alternates between one sample and none, because the following call completes the carried frame. So "every call but the last" was never true.

I kept the aligned sizes rather than dropping them: they are worth having as a control, since the point of the test is that the result does not depend on the split either way. The comment now says which are which and why both are there.

Tests still pass (99 total, 7 in AudioProcessor).

@lalinsky
lalinsky merged commit 41052e0 into master Jul 28, 2026
27 checks passed
@lalinsky
lalinsky deleted the test-unaligned-consume branch July 28, 2026 06:08
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